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
|
#include<iostream>
#include<cstring>
using namespace std;
class part
{
private:
char part_name[30];
int part_number;
double cost;
public:
void get_part(char name[], int pn, double c)
{
strcpy(part_name,name);
part_number=pn;
cost=c;
}
void show_part()
{
cout << "Part Name" << part_name;
cout << "\nPart Number " << part_number;
cout << "\n Cost= " << cost;
}
};
int main()
{
part p1,p2,p3,p4,p5,p6;
p1.get_part("Monitor",1,5000.00);
p2.get_part("Mother Board",2,3000.00);
p3.get_part("Processor" ,3,7000.00);
p4.get_part("HDD ",4,4000.00);
p5.get_part("RAM",5,3000.00);
p6.get_part("Cabinet & Others",6, 3000);
cout << "Computer Price:- \n\n";
cout << p1.show_part();
cout << p2.show_part();
cout << p3.show_part();
cout << p4.show.part();
cout << p5.show_part();
cout << p6.show.part();
return 0;
}
|