oop c++
Suppose that you are running a showroom and you deal in cars and jeeps. The price of a new car is
20,000$ and price of a jeep is 35,000$. You want to design a system for your daily earnings that tells
you the total vehicles sold and total cash received. Your program must tell you that how many cars
and jeeps are sold, and the earning of cars and jeeps must be displayed separately. And in the end the
total earning and total vehicles must display.
#include <iostream>
using namespace std;
int cars = 0, jeeps = 0, priceCar = 20000, priceJeep = 35000,
carsSold = 0, jeepsSold = 0, totalSold = 0, carEarn = 0, jeepEarn = 0, totalEarn = 0;
void sell_car(){
if(cars >= carsSold){
carEarn = carsSold * priceCar;
totalEarn += carEarn;
totalSold += carsSold;
}
else return;
}
void sell_jeep(){
if(jeeps >= jeepsSold){
jeepEarn = jeepsSold * priceJeep;
totalEarn += jeepEarn;
totalSold += jeepsSold;
}
else return;
}
int main(){
cout<<"Enter number of cars in the showroom: ";
cin>>cars;
cout<<"Enter number of jeeps in the showroom: ";
cin>>jeeps;
cout<<"Enter number of cars sold today: ";
cin>>carsSold;
cout<<"Enter number of jeeps sold today: ";
cin>>jeepsSold;
sell_car();
sell_jeep();
cout<<"***************************************\n";
cout<<"\tSold\tEarnings Today\n";
cout<<"Cars\t"<<carsSold<<"\t"<<carEarn<<endl;
cout<<"Jeeps\t"<<jeepsSold<<"\t"<<jeepEarn<<endl;
cout<<"Total\t"<<totalSold<<"\t"<<totalEarn<<endl;
return 0;
}
Comments
Leave a comment