Answer to Question #201168 in C++ for champu

Question #201168

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.


1
Expert's answer
2021-05-31T05:39:53-0400
#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;
}

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