write a programme that represent the object computer which has features such as Memory, storage, speed and brand. suggest at least one method in addition to to the constructor
#include<iostream>
#include<string>
using namespace std;
class Computer
{
double Memory;
double storage;
float speed;
string brand;
public:
Computer(){}
Computer(double _Memory, double _storage, float _speed,string _brand)
:Memory(_Memory), storage(_storage), speed(_speed), brand(_brand){}
void Assign()
{
cout << "Please, enter a memory of computer: ";
cin >> Memory;
cout << "Please, enter a storage of computer: ";
cin >> storage;
cout << "Please, enter a speed of computer: ";
cin >> speed;
cout << "Please, enter a brand of computer: ";
cin >> brand;
}
void Display()
{
cout << "\nInfo about computer: "
<< "\nMemory: " << Memory
<< "\nStorage: " << storage
<< "\nSpeed: " << speed
<< "\nBrand: " << brand;
}
};
int main()
{
Computer a(204800, 20000000, 100000, "IBM");
Computer b;
b.Assign();
a.Display();
b.Display();
}
Comments
Leave a comment