jeudi 22 septembre 2016

Homework. Yes No with Multiple Selections C++

So I'm having trouble writing the code so that the different items that are chosen are added together and the output is the Subtotal, Tax and Total. Here's what I have so far:

   #include <iostream>
   #include <math.h>

   /* run this program using the console pauser or add your own getch system("pause") or input loop */

   using namespace std;

int main() {

double meat = 3.5; 
double vegetable = 1.5;
double veggie = 1.2;  
double dessert = 2.5; 
double drink = 1.7;
double tax;
char response;
int orderTotal;

tax = (.9 * orderTotal);


//orderTotal = 0;
do
{
cout << "Would you like to include meat with your meal?(Y/N)" << endl;
cin >> response;
}
while( !cin.fail() && response!='y' && response!='n' );

do
{
cout << "Would you like to include a vegetable with your meal?(Y/N)" <<        endl;
cin >> response;
}
while( !cin.fail() && response!='y' && response!='n' );
do
{
cout << "Would you like to another vegetable with your meal?(Y/N)" << endl;
cin >> response;
}
while( !cin.fail() && response!='y' && response!='n' );
do
{
cout << "Would you like to include dessert with your meal?(Y/N)" << endl;
cin >> response;
}
while( !cin.fail() && response!='y' && response!='n' );
do
{
cout << "Would you like to include drink with your meal?(Y/N)" << endl;
cin >> response;
}
while( !cin.fail() && response!='y' && response!='n' );
switch (orderTotal)
{           case 1:  //Meat only
{
cout << "Total:" << meat + tax  << endl;
break;
}

        case 2: //Vegetbale only
        {
            cout << "Total:" << vegetable + tax << endl;
            break;
        }

        case 3: //Veggie only
        {
            cout << "Total:" << veggie + tax << endl;
            break;
        }

        case 4: //Dessert only
        {
            cout << "Total:" << dessert + tax << endl;
            break;
        }


        case 5: //Drink only
        {
            cout << "Total:" << dessert + tax << endl;
            break;
        }


    //  for (int tax = 5; tax < 6; tax--)


   //   if (response == 'Y')
  //    {
  //        meat + orderTotal;
  //    }
 // else if (response == 'N')
 // {

//  }

 }  
 return 0;

}

I'm having the most trouble just thinking of how to write the code so that the selections will be added together.

Aucun commentaire:

Enregistrer un commentaire