I need to know how to input the following code into the complier for C++ code. I
ID: 3865715 • Letter: I
Question
I need to know how to input the following code into the complier for C++ code. It is from chapter 10 question #4.
// Start
// Declarations
// Automobile myAuto
// string vin
// string make
// string model
// string color
// output "Please enter the Vehicle Identification Number: "
// input vin
// output "Please enter the Make: "
// input make
// output "Please enter the Mode: "
// input model
// output "Please enter the color: "
// input color
// Set the VIN for myAuto
// Set the Make for myAuto
// Set the Model for myAuto
// Set the Color for myAuto
// output "VIN: ", myAuto.getVin()
// output "Make: ", myAuto.getMake()
// output "Model: ", myAuto.getModel()
// output "Color: ", myAuto.getColor()
// Stop
Explanation / Answer
program.cpp ----
#include<iostream>
using namespace std;
class Automobile
{
private:
string vin;
string make;
string model;
string color;
public:
void setVin(string Vin){ vin = Vin; }
void setMake(string Make){ make = Make; }
void setModel(string Model){ model = Model; }
void setColor(string Color){ color = Color; }
string getVin(){ return vin; }
string getMake(){ return make; }
string getModel(){ return model; }
string getColor(){ return color; }
};
int main()
{
string vin, make, model, color;
cout<<" Please enter the Vehicle Identification NUmber : ";
cin>>vin;
cout<<" Please enter the Make : ";
cin>>make;
cout<<" Please enter the Model : ";
cin>>model;
cout<<" Please enter the color : ";
cin>>color;
Automobile myAuto;
myAuto.setVin(vin);
myAuto.setMake(make);
myAuto.setModel(model);
myAuto.setColor(color);
cout<<" Vin : "<<myAuto.getVin()<<endl;
cout<<" Make : "<<myAuto.getMake()<<endl;
cout<<" Model : "<<myAuto.getModel()<<endl;
cout<<" Color : "<<myAuto.getColor()<<endl<<endl;
return 0;
}