In C++ Please,
In the main(), below, write a program that uses a switch-statement to choose between three numbers. The number, choice, should be prompted for and each choice should print out a unique statement. Also, the prompt should continue indefinitely (i.e. keep prompting until the user force-quits the program), and there should be a general catch-all if the user enters other than the three possible choices.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
<your answer goes here>
return 0;
}
#include <iostream> using namespace std; int main() { int choice; char yOrN = 'Y'; while (yOrN == 'y' || yOrN == 'Y') { cout << "Chose either 1, 2, or 3: "; cin >> choice; switch (choice) { case 1: cout << "Good choice!" << endl; break; case 2: cout << "Terrible choice!" << endl; break; case 3: cout << "Amazing choice!" << endl; break; default: cout << "Unknown choice!" << endl; break; } cout << "\nDo you want to repeat again(y or n): "; cin >> yOrN; } return 0; }
Get Answers For Free
Most questions answered within 1 hours.