Write a C program which performs the following Ask user to e
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

