Answer to Question #322941 in C++ for Zizou

Question #322941

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


1
Expert's answer
2022-04-03T13:30:51-0400
#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();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS