---------->> These are what I've coded so far, the problem is, I don't know what to do next.. Do you have suggestions?? My codes aren't that good yet, I'm still revising it as of now.. BTW, how can I implement Classes in my codes?
Also, when the program starts again, the values inputted for the items become 0 again, like for the ice, when I order 20 cubes, it becomes 0 again when it starts from the top.
Well, there are two things that jump out at me immediately about your code that you should not be doing. You're using a goto statement and return EXIT_SUCCESS rather than return 0;
Consider someone else trying to understand your code and seeing three variables named sugar, shuga, and zugar, the latter two of which seem simply to be word plays on "sugar". What do these variables hold? From their names, it sounds like they are the same thing.
Okay, I've edited my codes.. This is what I have so far.. But there's an error, why does it keep looping when I enter a wrong choice??
What can I now do next??
Thanks for the replies earlier..
Your code is very unstructured and you are using goto! don't do that because you don't need it, go to is almost never used in programming, replace it with a while loop, the rest divide it into functions... How long do you program?
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
char choice;
int supplies[4];
double total=0;
start:
cout<< "Welcome to your lemonade stand!!";
cout<< endl;
cout<< "What would you want to do?";
cout<< endl;
cout<< endl<<"Check Supplies: Press S"<<endl;
cout<< "Check Orders: Press O"<<endl<<endl;
cin>> choice;
if (choice =='S')
{
int item;
int Nitem;
cout<<"Choose item: [Enter number]"<<endl;
cout<< "Ice: 1"<<endl;
cout<< "Lemons: 2"<<endl;
cout<< "Sugar: 3"<<endl;
cout<< "Cups: 4"<<endl;
cin>> item;
int totali;
if (item==1)
{
int i=2;
cout<<"You Have choosen Ice";
cout<<"Please enter No. of Amount You want: ";
cin>>Nitem;
totali=i*Nitem;
}
else if (item==2)
{
int l=10;
cout<<"You Have choosen Lemon";
cout<<"Please enter No. of Amount You want: ";
cin>>Nitem;
totali=l*Nitem;
}
else if (item==3)
{
int s=20;
cout<<"You Have choosen Sugar";
cout<<"Please enter No. of Amount You want: ";
cin>>Nitem;
totali=s*Nitem;
}
else if (item==4)
{
int c=15;
cout<<"You Have choosen Cups";
cout<<"Please enter No. of Amount You want: ";
cin>>Nitem;
totali=c*Nitem;
}
else
{
cout<<"Invalid Input";
}
total=totali;
}
else if (choice=='O')
{
cout<<"Your Total Orders are:"<<total;
}
else
cout<<"Sorry Your choices are S and 0 only";
system("PAUSE");
return 0;
}
Here's my new set of codes.. Can anyone see problems about it? How do I use classes for this kind of program? And how can I make it store the values that the user sets?