I have a project for school dealing with taxi orders along with miles used for varying taxi services with varying rates. My question or I guess what I would like help with is: my original menu is a switch and when I input the first option, it goes to the submenu which is another switch, but it should go back to the main menu to ask for another order. How do I change my code to do this?
It's output should look like this:
1. Order a pre-paid voucher
2. View cart
3. Exit
> 1
How many miles would you like to travel?
> 100
Which taxi company would you like to order with?
1. Checker Cab $30 + $0.00 per mile = $ 30.00
2. GTS Lawrence $ 5 + $0.20 per mile = $ 25.00
3. Jayhawk Taxi $ 0 + $1.10 per mile = $ 110.00
> 1
That will be $30.00
1. Order a pre-paid voucher
2. View cart
3. Exit
> 1
How many miles would you like to travel?
> 1000
Which taxi company would you like to order with?
1. Checker Cab $30 + $0.00 per mile = $ 30.00
2. GTS Lawrence $ 5 + $0.20 per mile = $ 205.00
3. Jayhawk Taxi $ 0 + $1.10 per mile = $1100.00
> 2
That will be $205.00
But my code ends after a value is inputted into the submenu. I need it to go back to the main menu so I can input more 'orders' I guess you could call them.
Any help would be appreciated! Thanks!
btw: first post to Cplusplus, please be considerate
while(choice!='3'&&choice!='2')
{
cout <<"==Menu=="<< endl<<"1. Order a pre-paid voucher"<<endl;
cout<<"2. View Cart"<<endl<<"3. Exit"<<endl;
cin>>choice;
switch(choice)
{
case '1':
cout<<"How many miles would you like to travel?"<<endl;
cin>>miles;
cout<<endl;
if(miles<=0)
{
cout<<"The value entered is invalid. Please input a value that is larger than 0"<<endl<<endl;
}
else
{
cout<<"Which taxi company would you like to travel with?"<<endl;
cout<<"1. Checker Cab $30+$0.00 per mile = $30"<<endl;
cout<<"2. GTS Lawrence $5+$0.20 per mile= $"<<5+(.20)*(miles)<<endl;
cout<<"3. Jayhawk Taxi $0+$1.10 per mile= $"<<1.10*(miles)<<endl;
cin>>choice2;
}
do
{
switch(choice2)
{
case '1':
cout<<"That will be $30"<<endl;
CheckOrder++;
continue;
case '2':
cout<<"That will be $"<<5.00+0.20*miles<<endl;
GTSOrder++;
continue;
case '3':
cout<<"That will be $"<<1.10*miles<<endl;
JayOrder++;
continue;
}
if(choice2!='1'&&choice2!='2'&&choice2!='3')
{
cout<<"Invalid input! Please try again!"<<endl<<endl;
}
else
{
break;
}
}
while(choice2=='1'&&choice2=='2'&&choice2=='3');
break;
case '2':
cout<<"You have a total of"<<endl;
cout<<"$ "<<calculateChecker<<" pending with Checker Cab"<<endl;
cout<<"$ "<<calculateGTS<<" pending with GTS Lawrence"<<endl;
cout<<"$ "<<calculateJayhawk<<" pending with Jayhawk taxi"<<endl;
break;
case '3':
cout<<"Have a nice trip!"<<endl;
break;
}