An application for Cody’s Car Care:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
vector<string>stroptions(4);
stroptions[0] = "Oil Change";
stroptions[1] = "Tire Rotation";
stroptions[2] = "Battery Check";
stroptions[3] = "Brake Inspection";
vector<int> intprices(4);
intprices[0] = 45;
intprices[1] = 22;
intprices[2] = 15;
intprices[3] = 10;
int option;
cout<< "Welcome to Joe's Car Care Shop!" <<endl;
cout<< "Choose a service from our menu:" <<endl;
for(int i = 1; i<= 4; i++)
{
cout<< "#" <<i<< ": " <<stroptions[i-1] <<endl;
}
cout<< "Choice: ";
bool loop = true;
while(loop)
{
loop = false;
cin>> option;
switch(option)
{
case 1:
cout<< "\nA " <<stroptions[option-1] << " will be: $" <<intprices[option -1] <<endl;
break;
case 2:
cout<< "\nA " <<stroptions[option -1] << " will be: $" <<intprices[option -1] <<endl;
break;
case 3:
cout<< "\nA " <<stroptions[option -1] << " will be: $" <<intprices[option -1] <<endl;
break;
case 4:
cout<< "\nA " <<stroptions[option -1] <<" will be: $" << intprices[option -1] <<endl;
break;
default:
cout<< "\nYou entered an invalid item! Try again!" <<endl;
loop = true;
break;
}
}
}