468,484 Members | 1,761 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,484 developers. It's quick & easy.

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<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";
}
Oct 21 '06 #1
0 816

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by JKop | last post: by
6 posts views Thread by KevinD | last post: by
9 posts views Thread by kfeder | last post: by
6 posts views Thread by Robbie Hatley | last post: by
7 posts views Thread by Brian C | last post: by
3 posts views Thread by stdlib99 | last post: by
7 posts views Thread by CSharper | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.