Help with an assignment

How would you complete this : (this assignment was already turned in)

#include <iostream>
#include <iomanip>

// if / else 3.6 page 73
// while 3.7 page 78
// sentinels 3.9 page 84
// iomanip 3.9 page 91
// increment / decrement 3.12 page 97
// for-loop 4.3 page 118
// do-while 4.5 page 126
// Switch 4.6 page 128
// break / continue 4.7 page 135
// Logical Operators 4.8 page 137

int main()
{
int quoteNumber = 1;
bool customerHappy = false; // are they happy with car?
int carSelection = 0; // used to capture selected car
double carCost = 0; // car cost alone
double upgradeCost = 0; // upgrade cost alone
double totalCost = 0; // car plus upgrades cost

// You are going to DOOO something until the customer has
// selected a car and is happy
do
{
// if(true) will ALWAYS be activated
// TODO: Make this loop run if we haven't selected a car
// yet - get the customer to select one
// if carSelection == 0, then they haven't picked a car yet (hint hint)
if (true)
{
std::cout << "Welcome to Bob's used car lot and chop shop!" << "\n";
std::cout << "As you can see we have quite a few to choose from!" << "\n";
std::cout << "Which one would you like?:" << "\n";
std::cout << "[1] 2005 Vokswagen Beetle ($8,000)" << "\n";
std::cout << "[2] 2008 Pontiac G6 ($8,581)" << "\n";
std::cout << "[3] 2004 Chevy S-10 ($10,500)" << "\n";
std::cout << "[4] 2016 Jeep Patriot ($15,209)" << "\n";
std::cout << "[5] 2012 Jeep Wrangler Sport ($24,390)" << "\n";

std::cout << "Which car would you like?: ";
std::cin >> carSelection;

// TODO: If the user makes a bad selection, tell them
// TODO: Else, set the carCost and move on to upgrades
// ----------------------------------------------
// Put your code in here! --> hint: use a switch
// ----------------------------------------------
// switch(carSelection)...


// ----------------------------------------------

// This newline will create a space between menus
std::cout << "\n";
}
else // Otherwise try to sell them some upgrades!
{
int upgradeSelection = 0; // The users menu choice
int engineLevel = 0; // the upgrade level of engine (0-5 only)
int tireLevel = 0; // the upgrade level of tire (0-5 only)
int rimLevel = 0; // the upgrade level of rims (0-5 only)
int paintLevel = 0; // the upgrade level of paint (0-5 only)
int mufflerLevel = 0; // the upgrade level of muffler (0-5 only)


// while(true) will NEVER stop running
// TODO: Make this while loop exit based on user input
while (true)
{
/////////////////////////////////////////////////////
// TODO: Calculate all of the upgrade costs here
/////////////////////////////////////////////////////
// Upgrades are $100 per level plus the cost of lower upgrades
// Example: Level 1 upgrade is $100
// Example: Level 2 upgrade is $100 + $200 = $300
// Example: Level 3 upgrade is $100 + $200 + $300 = $600
// etc etc etc etc etc etc etc etc etc etc etc etc etc...
// Hint: You might find a for-loop helpful for accumulating an amount
upgradeCost = 0;
//////////////////////////////////////////////////////
// Put your code below each of the comments marked
// for each upgrade type
//////////////////////////////////////////////////////
// Calculate upgrade cost for engine
// i.e. Put code here for engine...
// Calculate upgrade cost for tires
// i.e. Put code here for tires...
// Calculate upgrade cost for rims
// etc
// Calculate upgrade cost for paint
// Calculate upgrade cost for muffler
//////////////////////////////////////////////////////


//////////////////////////////////////////////////////
// TODO: Make the quote lines below print to look like money
// Example 3.45234 should be --> 3.45
// Think about iomanip
// ---------------------------------------
// Put some code in here
// ---------------------------------------




// ---------------------------------------
// ============================================================
// Don't mess with these lines ================================
// ============================================================
std::cout << "[" << quoteNumber++ << "] "; // Don't touch me
std::cout << " Car($" << carCost << ")"; // Don't touch me
std::cout << " E(" << engineLevel << ")"; // Don't touch me
std::cout << " T(" << tireLevel << ")"; // Don't touch me
std::cout << " R(" << rimLevel << ")"; // Don't touch me
std::cout << " P(" << paintLevel << ")"; // Don't touch me
std::cout << " M(" << mufflerLevel << ")"; // Don't touch me
// Don't touch the following line -- HOWEVER, you should put
// something in the space ABOVE to make this line print like money
std::cout << " Upgrades($" << upgradeCost << ")" << std::endl; // Don't touch me
// ============================================================

// Leave this menu the way it is
std::cout << "Do you want to upgrade your car?\n";
std::cout << "[-/+1] Downgrade / Upgrade Engine\n";
std::cout << "[-/+2] Downgrade / Upgrade Tires\n";
std::cout << "[-/+3] Downgrade / Upgrade Rims\n";
std::cout << "[-/+4] Downgrade / Upgrade Paint\n";
std::cout << "[-/+5] Downgrade / Upgrade Muffler\n";
std::cout << "[ 6] Clear all upgrades\n";
std::cout << "[ 7] Reset car\n";
std::cout << "[ 8] Buy Car!!!\n";
std::cout << "What would you like to do?: ";
std::cin >> upgradeSelection; // can be positive or negative

// TODO: Now operate on the user's selection
// TODO: If the user makes a bad selection, tell them
// -----------------------------------------------------------
// Put your code in here! --> hint: what did you do last time?
// -----------------------------------------------------------



// -----------------------------------------------------------


// This newline will create a space between menus
std::cout << "\n";
}
}

// Once again, a while(true) loop will never exit
// TODO: Make this loop exit when a car is selected and the customer is happy
} while (true);

/////////////////////////////////////////////////
// Do not modify these lines
/////////////////////////////////////////////////
totalCost = carCost + upgradeCost; // Don't touch me
std::cout << "Bill: Car($" << carCost << ")"; // Don't touch me
std::cout << " Upgrades($" << upgradeCost << ")"; // Don't touch me
std::cout << " Total ($" << totalCost << ")\n"; // Don't touch me
/////////////////////////////////////////////////

// these will stop the window from closing
std::cout << "Press ENTER to continue";
std::cin.ignore();
std::cin.get();
}
We aren't going to do the assignment for you, not even parts of it. Tell us what you are stuggling with and we will do our best to provide examples that you can use to finish it yourself
Well, as stated before I already have done this assignment but the area that I was having the most trouble with was in calculating the upgrades and having the compiler be able to increment and decrement by user input.
What I was told was using a for statement that looked something like this :

while (upgradeSelection != 8 && upgradeSelection =! 7 )

upgradeCost = 0;

for (int E = 1; E <= engineLevel; E++)
upgradeCost = upgradeCost + 100 * E;

for (int T = 1; T <= tireLevel; T++)
upgradeCost = upgradeCost + 100 * T; etc....

it continues to go into a switch
for each input for each upgrade
Topic archived. No new replies allowed.