Write your question here.
how can I insert the do while in my program?? .. i need to display "Do you want to continue y-yes n-no, if yes, it will loop but if not it will stop..
if(ch==1)
{
clrscr();
cout<<" TYPES OF GALLONS\n1.Round\n2.Box";
cout<<"\nChoose: ";
cin>>a;
if(a==1)
{
clrscr();
cout<<"\n1-Gallon\tP35";
cout<<"\n2-Gallons\tP30";
cout<<"\n3-Gallons\tP25";
cout<<"\n4-OPTION";
cout<<"\nChoice: ";
cin>>option;
}
if(a==2)
{
clrscr();
cout<<"\n1-Gallon\tP35";
cout<<"\n2-Gallons\tP30";
cout<<"\n3-Gallons\tP25";
cout<<"\n\t\t4-Option";
cout<<"\nChoice: ";
cin>>option;
}
if(option==1)
{
clrscr();
cout<<"\nWATER STATION";
cout<<"\n\nOrdered Gallon: "<<option;
cout<<"\nThe amount is "<<option*35;
cout<<"\nEnter Payment: ";
cin>>amount;
if(amount<option*35)
{
cout<<"\nSORRY ! THE AMOUNT IS NOT ENOUGH";
}
else
{
cout<<"\nThank you!\nYour Change is: "<<amount-option*35;
cout<<"Do you want to continue\ny-yes\nn-no";
cin>>n;
}
}
else if(option==2)
{
clrscr();
cout<<"\nWATER STATION";
cout<<"\n\nOrdered Gallon: "<<option;
cout<<"\nThe amount is "<<option*30;
cout<<"\nEnter Payment: ";
cin>>amount;
if(amount<option*30)
{
cout<<"\nSORRY ! THE AMOUNT IS NOT ENOUGH";
}
else
{
cout<<"\nThank you!\nYour Change is: "<<amount-option*30;
}
}
else if(option==3)
{
clrscr();
cout<<"\nWATER STATION";
cout<<"\n\nOrdered Gallon: "<<option;
cout<<"\nThe amount is "<<option*25;
cout<<"\nEnter Payment: ";
cin>>amount;
if(amount<option*25)
{
cout<<"\nSORRY ! THE AMOUNT IS NOT ENOUGH";
}
else
{
cout<<"\nThank you!\nYour Change is: "<<amount-option*25;
}
}
else if(option==4)
{
clrscr();
cout<<"Enter desired number of gallons to be delivered: ";
cin>>gallon1;
clrscr();
cout<< gallon1 <<" gallons x P20";
cout<<"\nAmount:"<<gallon1*20;
cout<<"\nCash: ";
cin>>amount;
if(amount<gallon1*20)
{
cout<<"\nSORRY ! THE AMOUNT IS NOT ENOUGH";
}
else
{
cout<<"\nThank you!\nYour Change is: "<<amount-gallon1*20;
}
}
else
{
cout<<"";
}