Help!!!! with my assingment

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • minterman
    New Member
    • Jan 2007
    • 7

    Help!!!! with my assingment

    I need to make a menu for my class assignment. It needs to be for different products. 1. read in an order of a customer of three items. each item to have a code. need to define a variable. prints a output with a random customer number.
    correct price for each order or a message sorry we dont carry this order.
    here is what I came up with so far. I am lost now



    #include <iostream>
    #include <string>
    #include <cstdlib>
    using namespace std;

    int main()
    {
    float S,L,F,D;
    total=0;
    string mystring= "Welcome to Minter's Resturant";

    cout << mystring << endl;
    cout << "Enter S for Shrimp, L for Lobster, F for Fish, and D for Drink" << endl;
    cout<< "Please enter order" << endl;

    while ("S")
    { total= total+10.00;
    }
    else if ("L")
    { total=total+ 35.00;
    }
    else if ("F")
    {total=total+ 6.00;
    }
    else if ("D")
    {total=total+1. 00;
    }
    cout << "Thank you customer ( randl)" <<endl;
    return 0;
    }
  • nickyeng
    Contributor
    • Nov 2006
    • 252

    #2
    i'm not sure the one i done is suit with your requirement, but this is the simple example.

    Next time use for your source code.


    Code:
    #include <iostream>
    #include <string>
    #include <cstdlib>
    using namespace std;
     
    int main()
    {
         [b]char choice;[/b]
         double total=0;
         string mystring= "Welcome to Minter's Resturant";
    
        cout << mystring << endl;
        cout << "Enter S for Shrimp, L for Lobster, F for Fish, and D for Drink" << endl;
        cout<< "Please enter order[b]:";[/b]
    
        cin >> choice;
        switch(choice)  {
              case S:
                      total= total+10.00;
                      cout << "Your choice is: " << choice << ". And the price is $ " << total << endl;
                      break;
              case L:
                      total=total+ 35.00;
                      cout << "Your choice is: " << choice << ". And the price is $ " << total << endl;
                      break;
              case F:
                      total=total+6.00;
                      cout << "Your choice is: " << choice << ". And the price is $ " << total << endl;
                      break;
               case D:
                      total=total+1.00;
                      cout << "Your choice is: " << choice << ". And the price is $ " << total << endl;
                      break;
               default:
                      cout << "We not carry this item" << endl;
                      break;
                 }
    
    }
    
    cout << "Thank you customer  ( randl)" <<endl;
    return 0;
    }

    Comment

    • minterman
      New Member
      • Jan 2007
      • 7

      #3
      Originally posted by nickyeng
      i'm not sure the one i done is suit with your requirement, but this is the simple example.

      Next time use for your source code.


      Code:
      #include <iostream>
      #include <string>
      #include <cstdlib>
      using namespace std;
       
      int main()
      {
           [b]char choice;[/b]
           double total=0;
           string mystring= "Welcome to Minter's Resturant";
      
          cout << mystring << endl;
          cout << "Enter S for Shrimp, L for Lobster, F for Fish, and D for Drink" << endl;
          cout<< "Please enter order[b]:";[/b]
      
          cin >> choice;
          switch(choice)  {
                case S:
                        total= total+10.00;
                        cout << "Your choice is: " << choice << ". And the price is $ " << total << endl;
                        break;
                case L:
                        total=total+ 35.00;
                        cout << "Your choice is: " << choice << ". And the price is $ " << total << endl;
                        break;
                case F:
                        total=total+6.00;
                        cout << "Your choice is: " << choice << ". And the price is $ " << total << endl;
                        break;
                 case D:
                        total=total+1.00;
                        cout << "Your choice is: " << choice << ". And the price is $ " << total << endl;
                        break;
                 default:
                        cout << "We not carry this item" << endl;
                        break;
                   }
      
      }
      
      cout << "Thank you customer  ( randl)" <<endl;
      return 0;
      }
      1>c:\documents and settings\welcom e\my documents\visua l studio 2005\projects\c ake\cake\food.c pp(35) : error C2065: 'S' : undeclared identifier
      1>c:\documents and settings\welcom e\my documents\visua l studio 2005\projects\c ake\cake\food.c pp(35) : error C2051: case expression not constant
      1>c:\documents and settings\welcom e\my documents\visua l studio 2005\projects\c ake\cake\food.c pp(39) : error C2065: 'L' : undeclared identifier
      1>c:\documents and settings\welcom e\my documents\visua l studio 2005\projects\c ake\cake\food.c pp(39) : error C2051: case expression not constant
      1>c:\documents and settings\welcom e\my documents\visua l studio 2005\projects\c ake\cake\food.c pp(43) : error C2065: 'F' : undeclared identifier
      1>c:\documents and settings\welcom e\my documents\visua l studio 2005\projects\c ake\cake\food.c pp(43) : error C2051: case expression not constant
      1>c:\documents and settings\welcom e\my documents\visua l studio 2005\projects\c ake\cake\food.c pp(47) : error C2065: 'D' : undeclared identifier
      1>c:\documents and settings\welcom e\my documents\visua l studio 2005\projects\c ake\cake\food.c pp(47) : error C2051: case expression not constant
      1>c:\documents and settings\welcom e\my documents\visua l studio 2005\projects\c ake\cake\food.c pp(54) : warning C4065: switch statement contains 'default' but no 'case' labels
      1>c:\documents and settings\welcom e\my documents\visua l studio 2005\projects\c ake\cake\food.c pp(58) : error C2143: syntax error : missing ';' before '<<'
      1>c:\documents and settings\welcom e\my documents\visua l studio 2005\projects\c ake\cake\food.c pp(58) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
      1>c:\documents and settings\welcom e\my documents\visua l studio 2005\projects\c ake\cake\food.c pp(59) : error C2059: syntax error : 'return'
      1>c:\documents and settings\welcom e\my documents\visua l studio 2005\projects\c ake\cake\food.c pp(60) : error C2059: syntax error : '}'
      1>c:\documents and settings\welcom e\my documents\visua l studio 2005\projects\c ake\cake\food.c pp(60) : error C2143: syntax error : missing ';' before '}'
      1>c:\documents and settings\welcom e\my documents\visua l studio 2005\projects\c ake\cake\food.c pp(60) : error C2059: syntax error : '}'

      I tried to run the program and this is what I got.
      I will play with it some more but thanks I am really trying to learn this class

      Comment

      • nickyeng
        Contributor
        • Nov 2006
        • 252

        #4
        Code:
        #include <iostream>
        #include <string>
        #include <cstdlib>
        using namespace std;
         
        int main()
        {
             char choice;
             double total=0;
             string mystring= "Welcome to Minter's Resturant";
        
            cout << mystring << endl;
            cout << "Enter S for Shrimp, L for Lobster, F for Fish, and D for Drink" << endl;
            cout<< "Please enter order:";
        
            cin >> choice;
            switch(choice)  {
                  case 'S':
                          total= total+10.00;
                          cout << "Your choice is: " << choice << ". And the price is $ " << total << endl;
                          break;
                  case 'L':
                          total=total+ 35.00;
                          cout << "Your choice is: " << choice << ". And the price is $ " << total << endl;
                          break;
                  case 'F':
                          total=total+6.00;
                          cout << "Your choice is: " << choice << ". And the price is $ " << total << endl;
                          break;
                   case 'D':
                          total=total+1.00;
                          cout << "Your choice is: " << choice << ". And the price is $ " << total << endl;
                          break;
                   default:
                          cout << "We not carry this item" << endl;
                          break;
                     }
        
            cout << "Thank you customer  ( randl)" <<endl;
            return 0;
        }
        // new line here
        please learn C++ with beginning a learner book.
        if syntax you cant fix it yourself, then you will run into wall everytime you compile a program.
        good luck.

        Comment

        Working...