Write a C program which performs the following Ask user to e

Write a C++ program which performs the following: Ask user to enter from keyboard the sales info about 3 cars: Example CRV-3 150000.00 20.0 MRV-1 180000.00 20.0 CIVIC 82000.00 10.0 The fields in the above columns are: Vehicle Name: string Vehicle Price: float/double Profit Rate(%): float/double Displays the results for each car with the following info: Vehicle Name: string Total Price: float/double

Solution

vehicle.cpp :

#include<iostream.h>

#include<fstream.h>

#include<conio.h>

struct vehicle{

char VehicleName[20];

double VehiclePrice;

double ProfitRate;

double TotalPrice;

};

int main(){

clrscr();

char data[100];

vehicle v[3];

ifstream infile;

infile.open(\"car.txt\");

ofstream outfile;

outfile.open(\"showroom.txt\");

for(int i=0;i<3;i++){

infile>>v[i].VehicleName;

infile>>v[i].VehiclePrice;

infile>>v[i].ProfitRate;

v[i].TotalPrice = (v[i].VehiclePrice) + (v[i].VehiclePrice * v[i].ProfitRate/100);

outfile<<v[i].VehicleName<<\"\\t\"<<v[i].TotalPrice<<endl;

/*cout<<v[i].VehicleName<<\" \"<<v[i].VehiclePrice<<\" \"<<v[i].ProfitRate<<\" \"<<v[i].TotalPrice<<endl;*/

}

infile.close();

outfile.close();

getch();

return 0;

}

car.txt :

CRV-3 150000.00 20.0

MRV-1 180000.00 20.0

CIVIC 82000.00 10.0

showroom.txt :

CRV-3 180000

MRV-1 216000

CIVIC 90200

 Write a C++ program which performs the following: Ask user to enter from keyboard the sales info about 3 cars: Example CRV-3 150000.00 20.0 MRV-1 180000.00 20.
 Write a C++ program which performs the following: Ask user to enter from keyboard the sales info about 3 cars: Example CRV-3 150000.00 20.0 MRV-1 180000.00 20.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site