473,503 Members | 479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple Programming Error Somewhere :0

3 New Member
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 942

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

Similar topics

18
12554
by: Ken | last post by:
Hi. Can anyone refer me to any articles about the compatibility between c++ polymorphism and real-time programming? I'm currently on a real-time c++ project, and we're having a discussion...
11
2676
by: JKop | last post by:
Take the following simple function: unsigned long Plus5Percent(unsigned long input) { return ( input + input / 20 ); } Do yous ever consider the possibly more efficent:
6
3747
by: KevinD | last post by:
assumption: I am new to C and old to COBOL I have been reading a lot (self teaching) but something is not sinking in with respect to reading a simple file - one record at a time. Using C, I am...
6
5036
by: Martin Ortiz | last post by:
Which is best approach? Should Try + Catch be used to only deal with "catastrophic" events (like divide by zero, non-existant file, etc...etc...) Or should Try + Catch be used IN PLACE of...
9
372
by: kfeder | last post by:
Im new to C programming i wrote a simple program that displays A - F. Im having a problem displaying F to A. could someone help me . include <stdio.h> #include <stdlib.h> #include <string.h>...
6
4978
by: Robbie Hatley | last post by:
I'm maintaining a software project with 134 C++ files, some of them huge (as much as 10,000 lines each), and very few prototypes. The author's attitude towards prototypes was like this: ...
7
1268
by: Brian C | last post by:
Hello all, I have, what I'm sure is an idiotic question, but I can't seem to find an answer for it (probably looking in the wrong direction of course). I'm coming from numerous years in C...
3
1837
by: stdlib99 | last post by:
Hi, I have a simple question regarding templates and meta programming. I am going to try and work my way through the C++ Template Metaprogramming, a book by David Abrahams and Aleksey...
6
28857
kenobewan
by: kenobewan | last post by:
Congratulations! You are one of the few who realise that over 80% of errors are simple and easy to fix. It is important to realise this as it can save a lot of time. Time that could be wasted making...
7
1799
by: CSharper | last post by:
Yesterday I had a heated discussion with my colleagues on what is a data centric application and having business logic in sql. I have group of people who wants to include all the business logic in...
0
7203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7463
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5017
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1515
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
738
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
389
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.