Write a C++ program that will determine how much your club madeat last night’s p
ID: 3613682 • Letter: W
Question
Write a C++ program that will determine how much your club madeat last night’s pee-wee baseball game. Your club buys(wholesale) and sells (retail) Peanuts, Cracker Jacks, and hot dogsaccording to the following table:
Item: The Club’scost: Amount sold for:
HotDogs .39 2.00
Peanuts 1.10 1.50
CrackerJacks .82 1.00
Ask someone to enter the number of Hot Dogs, Peanuts, andCracker Jacks that the club brought to the game, and how much theyhad left at the end of the game. From that information, determineand display the total amount of money that should be in the cashregister, as well as what your club’s profit was on eachindividual item and the overall profit.
Explanation / Answer
#include <iostream> #include <iomanip> using namespace std;int main() { int hotDogs, peanuts,crackerJacks; int hotDogsLeft, peanutsLeft,crackerJacksLeft; float totalMoney, hotDogsProfit,peanutsProfit, crackerJacksProfit, totalProfit;
cout << "Number of hot dogsbrought: "; cin >> hotDogs; cout << "Number of peanuts brought:"; cin >> peanuts; cout << "Number of Cracker Jacksbrought: "; cin >> crackerJacks;
cout << "Number of hot dogsleftover: "; cin >> hotDogsLeft; cout << "Number of peanutsleftover: "; cin >> peanutsLeft; cout << "Number of Cracker Jacksleftover: "; cin >>crackerJacksLeft;
totalMoney = 2.0f*(hotDogs - hotDogsLeft)+ 1.5f*(peanuts - peanutsLeft) + 1.0f*(crackerJacks -crackerJacksLeft);
hotDogsProfit = (2.0f - .39f)*(hotDogs -hotDogsLeft); peanutsProfit = (1.5f - 1.1f)*(peanuts -peanutsLeft); crackerJacksProfit = (1.0f -.82f)*(crackerJacks - crackerJacksLeft);
totalProfit = hotDogsProfit +peanutsProfit + crackerJacksProfit;
cout << "Total money in register:$" << fixed << setprecision(2) << totalMoney<< endl; cout << "Hot dogs profit: $"<< hotDogsProfit << endl; cout << "Peanuts profit: $"<< peanutsProfit << endl; cout << "Cracker Jacks profit: $"<< crackerJacksProfit << endl; cout << "Total profit: $" <<totalProfit << endl;
return 0; }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.