Answer to Question #48855 in C++ for ehab

Question #48855
Write a program that can find the price of a car in a gallery and the price of the car
from specific made.
The Gallery has only 3 types of Cars Mercedes Benz, Opel and BMW.
Ask the dealer to input the car made; M for Mercedes Benz, O for Opel and B for
BMW. The program then must calculate the price for that car.
The prices are fixed as following
Mercedes Benz = 35000 JD, Opel=21000 JD and BMW=45000JD.
1
Expert's answer
2014-11-12T13:27:23-0500
#include <stdlib.h>
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <string>
using namespace std;
struct Car
{
string type;
string price;
};
int main()
{
Car gallery[3];
gallery[0].type = "Mercedes Benz";
gallery[0].price = "35000 JD";
gallery[1].type = "Opel";
gallery[1].price = "21000 JD";
gallery[2].type = "BMW";
gallery[2].price = "45000JD";
char c;
do
{
system("cls");
cout<<"Enter the type of car (M or O or B) : ";
cin>>c;
if (c != 'M' && c != 'O' && c != 'B')
{
system("cls");
cout<<"Error!!! Wrong input!!!"<<endl;
system("pause");
}
} while(c != 'M' && c != 'O' && c != 'B');
system("cls");
if (c == 'M') {cout<<"Type : "<<gallery[0].type<<" Price : "<<gallery[0].price<<endl;}
if (c == 'O') {cout<<"Type : "<<gallery[1].type<<" Price : "<<gallery[1].price<<endl;}
if (c == 'B') {cout<<"Type : "<<gallery[2].type<<" Price : "<<gallery[2].price<<endl;}
system("pause");
return 0;
}

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