Question: I need help to fix the code without(not) using a break and keep using while method #include #include using namespace std; //children and adult price

I need help to fix the code without(not) using a break and keep using while method

#include #include using namespace std; //children and adult price as constants const double CHILDREN_PRICE = 12.00; const double ADULT_PRICE = 26.50; //Main method int main() { // main method variables int childtix; int adulttix,count=0,confirmation_no=100; double childtotal,bal; double adulttotal,security_pay=15.00; double totalbill; double totalcash; double change; // print output title cout << " Chesapeake Amusement Park" << endl << endl; //Ask user to enter number of childrens and adults tickets

while(true) { cout << " Enter children tickets or -1 to Stop ..... "; cin >> childtix; if(childtix==-1) { break; }

cout << " Enter adults tickets:..................... "; cin >> adulttix;

count=childtix/4; childtotal = (childtix * CHILDREN_PRICE)-(count*CHILDREN_PRICE);

if(adulttix>5) { adulttotal = (adulttix * ADULT_PRICE)-3; } else { adulttotal = (adulttix * ADULT_PRICE); } if(adulttix+childtix>20 || childtix>=14) { // total calculations totalbill = childtotal + adulttotal+security_pay;; } else { totalbill = childtotal + adulttotal; } // displays output title, number of tickets,Price, Total price, Total cash, and change

cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); cout << " Chesapeake Amusement Park"; cout << " -------------------------"; cout << " Tickets Price Total "; cout << " Children " << setw(3) << childtix << setw(15) << CHILDREN_PRICE << setw(12) << childtotal; cout << " "; cout << " Adult " << setw(6) << adulttix << setw(15) << ADULT_PRICE << setw(12) << adulttotal; cout << " "; cout << setw(13) << childtix + adulttix<< endl; cout << " "; if(adulttix+childtix>20 || childtix>=14) cout << " Security\t\t\t " <

cout << " Total Bill "<< setw(20) << totalbill; cout << " ";

//Getting the Total cash. cout << " Cash Received ....... "; cin >> totalcash; bal=totalbill-totalcash; if(bal>0) { while(true) { cout<<"\t\tCash must be >= Total Bill"; cout << " Cash Received ....... "; cin >> totalcash; bal=totalbill-totalcash; if(bal==0) break; else if(bal>0) { continue; } else if(bal<0) { change=-(bal); break; } } }

cout << " Change " << setw(25) << change; cout << " "; cout<<" Confirmation Number = "< } system("pause"); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!