guys im having problem with the output ,when i make order it doesnt loop it at main choose do you have any sugesstion .seriously please help me
#include <iostream.h>
#include <stdlib.h>
cout<<"Enter your table number : ";
cin>>table_no;
do //supposeto loop here
{
cout<<"Choose a number\n";
cout<<"1=TO display menu\n";
cout<<"2=TO place customer order\n";
cout<<"3=TO diplay payment amount for customer order\n";
cout<<"4=Exit\n";
cin>>choose;
switch (choose)
{
case 1:
menu();
break;
case 2:
F_order();
break;
case 3:
pay();
break;
case 4:
exit(0);
break;
}
}
while (1);
}
void menu()
{
int move;
cout<<"What did your want to display?\n";
cout<<"1=Main dish\n";
cout<<"2=Desert\n";
cout<<"3=Drinks\n";
cout<<"4=Back to main menu\n";
cin>>move;
do
{
temp= new queue;
cout<<"Enter food code\n";
cin>>temp->kod;
temp->next=NULL;
if(front==NULL)
{
front=temp;
}
else
{
rear->next=temp;
rear=temp;
}
cout<<"would you like to add more y/n?"<<endl;
cin>>choice;
I see three things to get you started that you can work on:
PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.
2. The header file "iostream.h" does not exist. Loose the ".h". If you are not familiar with header file anything that ends in ".h" is a C header file. C++ does not use file extensions for the standard header files. These days when I write a header file for a C++ program I use the extension ".hpp" to go with the ".cpp" extension for the code files.
3. You need to qualify "cout", "cin" and "endl" with "std::". Do not use the line usingnamespace std; This WILL get you in trouble some day. The search and replace will make this easier.
Something to work on while I dig into your program.
You will find that insulting people who have something you want (in this case, knowledge) will make it less likely, rather than more likely, that they will help you.
You are very very bad at asking questions. This is going to be a big problem for you. The first way you are bad at asking questions is that you do not put your code in [code] tags [/code] , even though you have been asked to. You are making it difficult for people to read your code. Do you understand why that's a problem? It is insulting to them. You are making them do extra work to help you, a complete stranger. It is very impolite on your part.
You aren't fixing errors. You've been told before things that you keep doing.
void main() is wrong. Wrong wrong wrong.int main() is correct. You have been told this before, but we can all see that you are not fixing your code.
Why should we keep helping you if you don't accept our help?
Why should we keep helping you if you're going to insult us?
Your code crashes for the same reasons as before. Pointers that point to nothing. If you don't understand what we mean when we say that, then just say so. Just say "I am sorry; I don't understand what a pointer is, could you explain more simply please?" That's all you need to do.
Time for you to pick one. Grow up, start doing what we suggest, OR accept that you're not going to get this fixed and you're going to fail whatever class you're taking. This is your choice. Good luck.
its bullshit andy.i try that and it got more error .
plus you dont even try it .you just keep judging it
I have no patients for people who do not want to listen to what they are told. You only gave me 17 minutes to look into your code and that was not enough time to load the program, fix the errors and get it to compile before I could even test it.
I agree with Repeater your pointers point to nothing. It sounds like you have been told this before, so why should I cove what you already know.
im sorry andy , I was so stressed out about '.h' things
My lecturer told us to put '.h' and using namespace std; ,when you said.eliminate it ,I did ,but others said too put on it again. Im so.sorry to insult you guys that mostly experience about this.
if its getting stuck forever, try adding debugging lines. What I mean is, make the program output what it has in the variable that is being tested every time thru, so you can see it and figure out why the variable isn't what it's supposed to be.
sprinkle these cout statements anywhere you think they might help!
throw in a
cout << "\n" << ans << "\n"
after asking about ans, throw one in for numbers, etc etc .. you'll find out why the test is failing because you'll actually be able to see what's in the variables in your output. Sure, it'll make a mess of things, but you just remove or comment out those debugging lines after you're sure that part works.
It's funny how a lot of teachers will teach a programming class, but they never even bother to teach debugging at all. This leaves students skilled with only compiler output catching typos, but not being taught any skills to find actual coding errors. It's a horrible way to teach, and results in many frustrated students. I sympathize with you Helena.
if its getting stuck forever, try adding debugging lines. What I mean is, make the program output what it has in the variable that is being tested every time thru, so you can see it and figure out why the variable isn't what it's supposed to be.
Even better use a debugger, hopefully there is a GUI one in the IDE, other wise use a command line version. Set up a watch list of variables, step through the code 1 line at a time, see how the values change, deduce what went wrong. This has the advantages of not having to: Add output statements everywhere ; going back and deleting the output statements.
It seems this course you were taking was crap.
Why do you want to give it up completely?
Why don't you try sth. simpler ? http://mooc.fi/courses/2013/programming-part-1/
They have good course material + support channel
I accept your apology, but as hard as it is to do yo managed to hurt my feelings and that takes longer to get over.
I tell you that "using namespace std;" is a bad idea and a problem and you say its "bullshit". To that I say load this program and compile it then tell what happens: