Assume the definiton of Exercise 2 Declare a carType variable and write c++ stat
ID: 3819939 • Letter: A
Question
Assume the definiton of Exercise 2 Declare a carType variable and write c++ statements to store the following information Manufacturer - GMT, model - cyclone, type-sedan, color- blue, number of doors 4, miles per gallon in city 28, miles per gallon on highway 32, year when the car was built 2006, and the price--25000.00. (2)
Reference
Define a struct, carType, to store the following data about a car: Manufacturer (string), model (string), model type (string), color (string), number of doors (ant),miles per gallon in city (int) miles per gallon on highway (int), year when the car was buit (nt), and the price (double). (1)
please help me to do this using C++.
i need a working program
Explanation / Answer
#include <iostream>
#include <iomanip>
using namespace std;
struct carType //structure definition
{
string manufacturer;
string model;
string modelType;
string color;
int doors;
int mpgC;
int mpgH;
int year;
double price;
};
int main()
{
struct carType car = {"GMT","cyclone","sedan","blue",4,28,32,2006,25000.00};//initialization
cout<<fixed<<setprecision(2);
//display car attributes
cout<<"Car Details :";
cout<<" Manufacturer : "<<car.manufacturer;
cout<<" Model : "<<car.model;
cout<<" Model Type : "<<car.modelType;
cout<<" Color : "<<car.color;
cout<<" Number of doors : "<<car.doors;
cout<<" Miles per gallon in City : "<<car.mpgC;
cout<<" Miles per gallon on Highway : "<<car.mpgH;
cout<<" Built in year : "<<car.year;
cout<<" Price : "<<car.price;
return 0;
}
Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.