Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a class called CPU that consists of a manufacturer, a model number, and a

ID: 3841258 • Letter: C

Question

Create a class called CPU that consists of a manufacturer, a model number, and a speed in hertz. Create a constructor that requires all three data items and a function that will display the following output line where the bolded items represent data: "The CPU is made by Intel Model # z196 and has a speed of 5.2 GHZ".

Create a class called Motherboard that consists of manufacturer and a model number. Create a constructor that requires both data items and a function that will display the following output line where the bolded items represent data: "The Motherboard was made by Asus Model # I5-750".

Create a class called RAM that consists of a size and speed. Create a constructor that requires both data items and a function that will display the following output line where the bolded items represent the data: "The RAM size is 4 GB and has a spped of 1600 mps".

Create a class called PersonalComputer that consists of a manufacturer, model, as well as a CPU, Motherboard, and RAM. Create a constructor that uses an initilization list and a display function that displays the private data and calls the other display finctions for the data elements that are used in the composition. The constructor should display the following: "I am constructing a PC".

The main() function should create a vector of PersonalComputers and ask the user to enter data untilthe user decides to quit and then call the display function for the PersonalComputer only. Once the user is finished entering data, print your vector of PC's. Save the file as personalComputer.cpp.

Explanation / Answer

PROGRAM CODE:

#include <iostream>
using namespace std;

class CPU
{
   private:
   string manufacturer;
   string modelNumber;
   double speed;
   public:
   CPU(string m, string mn, double s)
   {
       manufacturer = m;
       modelNumber = mn;
       speed = s;
   }
   void display()
   {
       cout<<"The CPU is made by "<<manufacturer<<" Model # "<< modelNumber<< " and has a speed of "<<speed<<" GHZ"<<endl;
   }
};

class Motherboard
{
   private:
   string manufacturer;
   string modelNumber;
   public:
   Motherboard(string m, string mn)
   {
       manufacturer = m;
       modelNumber = mn;
   }
   void display()
   {
       cout<<"The Motherboard was made by "<<manufacturer<<" Model # "<< modelNumber<<endl;
   }
};

class RAM
{
   private:
   int size;
   int speed;
   public:
   RAM(int ram_size, int ram_speed)
   {
       size = ram_size;
       speed = ram_speed;
   }
   void display()
   {
       cout<<"The RAM size is "<<size<<" GB and has a speed of "<< speed<<" mps"<<endl;
   }
};

class PersonalComputer
{
   private:
   string manufacturer;
   string modelNumber;
   CPU *cpu;
   Motherboard *mb;
   RAM *ram;
   public:
   PersonalComputer(string pc_m, string pc_mn, string cpu_m, string cpu_mn, double cpu_s, string mb_m, string mb_mn,int rm_size, int rm_speed )
   {
       cout<<"I am constructing a PC"<<endl;
       manufacturer = pc_m;
       modelNumber = pc_mn;
       cpu = new CPU(cpu_m, cpu_mn, cpu_s);
       mb = new Motherboard(mb_m, mb_mn);
       ram = new RAM(rm_size, rm_speed);
   }
   void display()
   {
       cout<<"I was made by "<<manufacturer<<" Model # "<<modelNumber<<endl;
       cpu->display();
       mb->display();
       ram->display();
   }
};
int main() {
   PersonalComputer pc("Lenovo", "AS345", "Intel", "z234", 3.5, "Asus", "I5-135", 4, 1600);
   pc.display();
   return 0;
}

OUTPUT:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote