Simple Programming Error Somewhere :0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NeedHelp666
    New Member
    • Oct 2006
    • 3

    Simple Programming Error Somewhere :0

    Hi there, the following compiles fine, but when I run it, It does nothing. Could someone please help me? BTW, its supposed to show the menu, take the input, and spit out the resulting message. All help is appreciated, hope it doesn't take up too much time out of ur cs or wow playing. Thanx.

    #include<iostre am>
    using namespace std;
    void intsructions();
    int read_choice();
    void out_of_range();
    int menu();
    void output(int);
    int main()
    {
    int selection;
    menu();
    selection = menu();
    if (selection>0)
    output(selectio n);
    }
    void instructions ()
    {
    cout<<"Hello! I am a vending machine. I can dispense to you:";
    cout<<"1"<<""<< "chocolate candy bar";
    cout<<"2"<<""<< "peppermint s";
    cout<<"3"<<""<< "crackers";
    cout<<"4"<<""<< "ballpoint" ;

    cout<<"Please make your selection by number:";
    }
    int menu()
    {
    int output_2;
    int choice;
    if (choice>4)
    output_2=-1;
    else
    out_of_range();
    return output_2;
    choice=read_cho ice();
    instructions();
    }
    int read_choice(int choice)
    {
    int output_2;
    cin>>choice;
    if ((choice>=1)&&( choice<=4))
    output_2=choice ;
    else
    out_of_range();
    return(output_2 );
    }
    void out_of_range()
    {
    cout<<"You have entered an invalid selection number.";
    }
    void output(int selection)
    {
    if (selection ==1)
    cout<<"A chocolate bar costs $1.00. Please pay.\n";
    else if(selection ==2)
    cout<<"Peppermi nts cost $.75. Please pay.\n";
    else if(selection==3 )
    cout<<"Crackers cost $1.25. Please pay.\n";
    else
    cout<<"A ballpoint costs $1.25. Please pay.\n";
    }
Working...