When buying a Tesla Model 3, you have a choice between three versions/trims: 1) Standard Range Plus, 2) Long Range, and 3) Performance. All trims have the same base features, but the 2nd trim includes additional features, and the 3rd trim adds features on top of those from #2. In other words, the feature list is incremental.
Write a program that asks the user to choose which Model 3 they want to buy. You will then output the feature list based on the user's selection. So that you understand which feature list belongs to each, my example below is for the most expensive trim (Performance), which includes everything. I used an empty line to separate the features for each trim. Be sure to reject invalid menu choices.
Menu/Prompts:
Enter the letter that corresponds to your desired Tesla Model 3 from the choices below:
[S]tandard Range Plus
[L]ong Range
[P]erformance
Enter your choice: [Assume user enters P]
Output for 'P':
#include <iostream>
int main()
{
std::cout << "Enter the letter that corresponds to your desired Tesla Model 3 from the choices below: \n[S]tandard Range Plus\n[L]ong Range\n[P]erformance\nEnter your choice : ";
std::string answer;
std::cin >> answer;
if (answer == "S" || answer == "s")
{
std::cout << "Feature List:\n\n" <<
"Automatic emergency braking and collision avoidance warning\n3x3 point rear seat belts\n6 airbags - Driver, front passenger, curtainand side airbags\nTyre pressure monitor\nESC - Electronic Stability Control + traction control\nElectronic Stability Programme\nAnti - lock brake system\n";
}
else if (answer == "L" || answer == "l")
{
std::cout << "Feature List:\n\n" <<
"The Long Range edition of the Tesla Model 3 is all-wheel drive and promises an electric range\nof 360 miles. It features smaller 18in wheels and does without sports suspension, but otherwise\ngets similar kit to the Performance including electric adjustment for the front seats and steering\ncolumn, front and rear heated seats, premium audio, wireless phone charging and keyless\nentry.\n";
}
else if (answer == "P" || answer == "p")
{
std::cout << "Feature List:\n\n"<<
"- Performance wheels and brakes\n- Lowered suspension\n- Track mode\n\n- All wheel drive\n- 310 - mile battery range\n- Premium audio\n\n- All electric motor\n- Autopilot\n- 15 - inch touchscreen\n";
}
else
{
std::cout << "Invalid selection. Please run the program again.\n";
}
system("pause");
return 0;
}
Comments
Leave a comment