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<iostream>
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(selection);
}
void instructions ()
{
cout<<"Hello! I am a vending machine. I can dispense to you:";
cout<<"1"<<""<<"chocolate candy bar";
cout<<"2"<<""<<"peppermints";
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_choice();
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<<"Peppermints 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";
}