-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
117 lines (101 loc) · 4.56 KB
/
Copy pathmain.cpp
File metadata and controls
117 lines (101 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <iostream>
#include <cstdlib>
#include <fstream>
int userChoice;
class pricer // Class made for storing price and quantity of components.
{
public:
double CPU = 0.00, GPU = 0.00, MOBO = 0.00, PSU = 0.00, CASE = 0.00, RAM = 0.00; // Price of components.
int x_CPU = 0, x_GPU = 0, x_MOBO = 0, x_PSU = 0, x_CASE = 0, x_RAM = 0; // Quantity of components.
};
class tax
{
public:
double tax;
std::string state;
//void taxCalc(); // Will calculate state tax. (United States of America)
//void taxCalc()
//{
// Automatically calculate tax based on state selected by user. (United States of America)
//}
};
pricer price, quantity;
void fullBuild(), clear(), exportFile();
// Function that exports calculation results in a text file.
void exportFile()
{
std::ofstream exportFile("result.txt");
exportFile << "Calculation Visual...\n\n";
exportFile << "[CPU Cost] $" << price.CPU << " * " << quantity.x_CPU << " ---> $" << price.CPU * quantity.x_CPU << "\n";
exportFile << "[GPU Cost] $" << price.GPU << " * " << quantity.x_GPU << " ---> $" << price.GPU * quantity.x_GPU << "\n";
exportFile << "[MOBO Cost] $" << price.MOBO << " * " << quantity.x_MOBO << " ---> $" << price.MOBO * quantity.x_MOBO << "\n";
exportFile << "[PSU Cost] $" << price.PSU << " * " << quantity.x_PSU << " ---> $" << price.PSU * quantity.x_PSU << "\n";
exportFile << "[CASE Cost] $" << price.CASE << " * " << quantity.x_CASE << " ---> $" << price.CASE * quantity.x_CASE << "\n";
exportFile << "[RAM Cost] $" << price.RAM << " * " << quantity.x_RAM << " ---> $" << price.RAM * quantity.x_RAM << "\n\n";
exportFile << "You need to save roughly $" << price.CPU * quantity.x_CPU + price.GPU * quantity.x_GPU + price.MOBO * quantity.x_MOBO + price.PSU * quantity.x_PSU + price.CASE * quantity.x_CASE + price.RAM * quantity.x_RAM << "." << "\n\n";
exportFile.close();
}
// Portably clears the terminal/ console screen. --Windows, Mac, Linux
void clear()
{
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
}
void fullBuild()
{
clear();
// Collects all component prices & quantities from the user.
std::cout << "Simple PC Part Price Calculator [SPCPPC]\n\n";
std::cout << "[CPU price] ";
std::cin >> price.CPU;
std::cout << "[Quantity] ";
std::cin >> quantity.x_CPU;
std::cout << "[GPU price] ";
std::cin >> price.GPU;
std::cout << "[Quantity] ";
std::cin >> quantity.x_GPU;
std::cout << "[MOBO price] ";
std::cin >> price.MOBO;
std::cout << "[Quantity] ";
std::cin >> quantity.x_MOBO;
std::cout << "[PSU price] ";
std::cin >> price.PSU;
std::cout << "[Quantity] ";
std::cin >> quantity.x_PSU;
std::cout << "[CASE price] ";
std::cin >> price.CASE;
std::cout << "[Quantity] ";
std::cin >> quantity.x_CASE;
std::cout << "[RAM price] ";
std::cin >> price.RAM;
std::cout << "[Quantity] ";
std::cin >> quantity.x_RAM;
clear();
std::cout << "Simple PC Part Price Calculator [SPCPPC]\n\n";
// Displays visualization of calculations done by the program ("proof of work").
std::cout << "Calculation Visual...\n\n";
std::cout << "[CPU Cost] $" << price.CPU << " * " << quantity.x_CPU << " ---> $" << price.CPU * quantity.x_CPU << "\n";
std::cout << "[GPU Cost] $" << price.GPU << " * " << quantity.x_GPU << " ---> $" << price.GPU * quantity.x_GPU << "\n";
std::cout << "[MOBO Cost] $" << price.MOBO << " * " << quantity.x_MOBO << " ---> $" << price.MOBO * quantity.x_MOBO << "\n";
std::cout << "[PSU Cost] $" << price.PSU << " * " << quantity.x_PSU << " ---> $" << price.PSU * quantity.x_PSU << "\n";
std::cout << "[CASE Cost] $" << price.CASE << " * " << quantity.x_CASE << " ---> $" << price.CASE * quantity.x_CASE << "\n";
std::cout << "[RAM Cost] $" << price.RAM << " * " << quantity.x_RAM << " ---> $" << price.RAM * quantity.x_RAM << "\n\n";
// Displays total cost of components * quantiy of components each.
std::cout << "You need to save roughly $" << price.CPU * quantity.x_CPU + price.GPU * quantity.x_GPU + price.MOBO * quantity.x_MOBO + price.PSU * quantity.x_PSU + price.CASE * quantity.x_CASE + price.RAM * quantity.x_RAM << "." << "\n\n";
exportFile();
std::cout << "[Press any key to exit the program.]\n";
std::cin.ignore();
std::cin.get();
clear();
}
int main()
{
clear();
// This program is for me to get a rough estimate on how much I need to save to build pc parts.
std::cout << "Simple PC Part Price Calculator [SPCPPC]\n\n";
fullBuild();
return 0;
}