Question: how do I make my code only have one return 0; at the end but still get the same output, without using loops #include #include

how do I make my code only have one return 0; at the end but still get the same output, without using loops

#include #include using namespace std; int main() { int number, //holds the number of colors in the sign. base_price=0;//holds the base price of the sign based on the number of colors double lighted=0,//holds the price of the lighted sign option old=0, //holds the price of removing an old sign price=0;//holds the total price of the sign with all options included char ch; //holds the user input for whether they want a lighted sign //or need an old sign removed. //Print Tiltle cout << " HOMEWORK / CLASSWORK PART 2 "; // Prompt for and input the number of colors cout << "Enter the number of colors in the sign: "; cin >> number; //Validate the number of colors { if (number == 1) base_price = 250; else if (number == 2) base_price = 325; else if (number == 3) base_price = 450; else if (number == 4) base_price = 625; else if (number >= 5) base_price = 850; else { cout << "Invalid number,Please try again"; return 0; }} //Prompt for and input extra items wanted cout << "Do you want a lighted sign? (y or n) "; cin.ignore(); cin.get(ch); if (ch == 'y' ) { lighted = base_price * 0.25; } else if (ch == 'n' ) lighted = 0; else { cout << "Invalid Input"; return 0; } cout << "Do you need an old sign removed? (y or n) "; cin.ignore(); cin.get(ch); if (ch == 'y' ) { old = base_price * 0.1; } else if (ch == 'n' ) old = 0; else { cout << "Invalid Input"; return 0; } price = base_price + old + lighted; //Output the total price cout << fixed << setprecision(2); cout << "The price is $" << price<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!