nested if programm

somebody help me to make thisprogramm




The user display shows a start-up message welcoming the customer and invites him/her to proceed by pressing A key on the keypad.
On pressing A key a menu is displayed offering four choices of drinks and an option to cancel.When a choice has been made the display indicates the drink chosen along with its price and an option to continue. Each of the drinks has a different price.
If the option chosen is not to continue the user is returned to the welcome screen. Conversely, if the user elects to continue then a question requesting the quantity required is displayed
Sure, I'll begin it for you and you can finish it =)



Goodluck =)
Last edited on
Man.... i know how to start

its difficult for me to complete please do something
its difficult for me to complete please do something

No "Man", you do something. This is your homework or whatever. Read the links I gave you, use google, use youtube and make the program yourself.

However, if you get stuck on a specific problem, we'll be glad to help you =) But you gotta show us the code you've written so far.
Last edited on
hi TarikNeaj
i write code for 1 drink

it gives an error
please check it out




#include<iostream.h>
#include<conio.h>
void main()
{
char ch,again;
int n;
do
{
cout<<"Welcome Customers";
cout<<endl;
cout<<"please press A on the keyboard "<<endl;
cin>>ch;
switch(ch)
{
case 'A':
cout<<"1:Coca Cola"<<endl;
cout<<"2:7up"<<endl;
cout<<"3:Pepsi"<<endl;
cout<<"4:Sprite"<<endl;
cout<<endl;
cout<<"Enter Your Choice:"<<endl;
cin>>n;
if(n==1)
{
cout<<"Cocacola:"<<"Price=25Rs/per"<<endl;
cout<<"press C to continue:"<<endl;
cin>>ch;
if(ch=='C')
{
cout<<"Enter Quantity"<<endl;
cin>>n;
break;
default:
cout<<"invalid choice"<<endl;
}
}
cout<<endl;
cout<<"Enter A to return"<<endl;
cin>>again;
}
while(again=='A');
}
getch();
}

the error is (do statement must have while)
Hey,

Im surprised no one has told you in your previous post, but please use code tags for all your code, to make it easier to read - http://www.cplusplus.com/articles/jEywvCM9/

Your problem is that the while part of your do-while loop is inside the do brackets, it should be outside.

How it should be :
1
2
3
4
do
{

}while()


How yours is -

1
2
3
4
do
{
   while()
}


So simply move it to its correct position -

1
2
3
4
5
6
7
8
9
10
default:
			cout << "invalid choice" << endl;
				}
			}
			cout << endl;
			cout << "Enter A to return" << endl;
			cin >> again;
		}
		
	} while (again == 'A');
thank you very much
tarikneaj
Topic archived. No new replies allowed.