Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Objective:write a class program of computer accessory.

//class of student informtaion


#include "iostream"
#include "string"
using namespace std;
class computer
{
private:
string mname;
string ram;
string proccessor;
string harddrive;
string graphic;
string monitor;
string printer;
string window;
char ch;

public:
void getdata()
{
cout<<"enter the mod name of computer:"<<endl;
cin>>mname;
cout<<"enter the ram(random access memory):"<<endl;
cin>>ram;
cout<<"enter the proccessor capacity:"<<endl;
cin>>proccessor;
cout<<"enter the hard drive capacity:"<<endl;
cin>>harddrive;
cout<<"enter the grapher card support:"<<endl;
cin>>graphic;
cout<<"enter the monitor modle:"<<endl;
cin>>monitor;
cout<<"enter the whather printer or none:"<<endl;
cin>>printer;
cout<<"enter the windows:"<<endl;
cin>>window;
cout<<" "<<endl;
}
void display()
{
cout<<"modle name \t:"<<mname<<endl;
cout<<"ram (random acces memory: \t"<<ram<<endl;
cout<<"proccessor: \t"<<proccessor<<endl;
cout<<"hard drive capacity: \t"<<harddrive<<endl;
cout<<"graphic supporter: \t"<<graphic<<endl;
cout<<"monitor: \t"<<monitor<<endl;
cout<<"printer : \t"<<printer<<endl;
cout<<"current windows:\t"<<window<<endl<<endl;
}
void updatepart()
{
char ch;
cout<<"to update press [y]\nto end press [n]"<<endl;
cin>>ch;
if (ch=='y')
{
int x;
cout<<"to update computer parts chose part"<<endl;
cout<<"1 for ram\n2 for proccessor\n3 hard drive\n4 for
graphic\n5 for monitor\n6 printer"<<endl;
cin>>x;
switch(x)
{
case 1:
cout<<"update ram:"<<endl;
cin>>ram;
break;
case 2:
cout<<"proccessor :"<<endl;
cin>>proccessor;
break;
case 3:
cout<<"update hard drive :"<<endl;
cin>>harddrive;
break;
case 4:
cout<<"update graphic:"<<endl;
cin>>graphic;
break;
case 5:
cout<<"update monitor"<<endl;
cin>>monitor;
break;
case 6:
cout<<"update printer"<<endl;
cin>>printer;
break;
default: cout<<"error in valid input"<<endl;
}

}
else if(ch=='n'){cout<<"\t\tYOU CHOOSE TO END \t\t"<<endl;}
}
};
void main()
{
computer no1;
no1.getdata();
no1.display();
no1.updatepart();
no1.display();

You might also like