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
|
#include<iostream>
#include<string>
#include<fstream>
const int size = 5;
struct Computer
{
string processor[size];
string motherboard[size];
};
struct Prices
{
double proc_prices[size];
double mboard_prices[size];
};
void display_proc(struct Computer comp, struct Prices price);
void display_moth(struct Computer comp, struct Prices price);
int main(){
int chosen_proc, chosen_moth;
Computer computer = {
{"1. Asus Prime A320M-K AMD AM4 uATX MotherBoard with LED lighting, DDR4 3200MHz, 32Gb/s M.2, HDMI, SATA 6Gb/s, USB 3.0","2. MSI H410M-A PRO LGA 1200 Supports 10th Gen Intel Core and Pentium Gold / Celeron processors"}, // processsor array init
{"1. Intel Pentium Dual Core G2030 3.0Ghz 3MB Cache LGA1155 22nm Processor", "2. Intel Core i3-7100 Processor (3M Cache, 3.90 GHz)"} // motherboard array init
};
Prices all_prices = {
{2499, 5999},
{2999, 3999}
};
system("Color 0A");
ofstream proc1("processor.txt", ios::app);
ofstream mother1("motherboard.txt", ios::app);
cout <<"Choose your Processor!" << endl;
if(proc1.is_open()){
display_proc(computer, all_prices);
proc1.close();//file close
}
else{
cout<<"Error in file opening"<<endl;
}
cout <<"Enter a number: ";
cin >> chosen_proc;
cout <<"Choose your Motherboard!" << endl;
if(mother1.is_open()){
display_moth(computer, all_prices);
mother1.close();//file close
}
else{
cout <<"Error in file opening" << endl;
}
cout <<"Enter a number: ";
cin >> chosen_moth;
}
void display_proc(struct Computer comp, struct Prices price)
{
for(int i = 0; i < size; i++)
{
cout << comp.processor[i] << " " << endl
<< "Price: Php"<< price.proc_prices[i] << endl;
}
}
void display_moth(struct Computer comp, struct Prices price)
{
for(int i = 0; i < size; i++)
{
cout << comp.motherboard[i] << " " << endl
<< "Price: Php"<< price.mboard_prices[i] << endl;
}
}
|