Answer to Question #286318 in C++ for You

Question #286318

Write a program on ticket purchasing discount in cinemal hall

1
Expert's answer
2022-01-10T11:18:48-0500
#include <iostream>
using namespace std;
int main(){
    int count;
    int choice;
    float amount;
    do{
        cout<<"1. Purchase Ticket(s)\n";
        cout<<"0. Exit\n";
        cin>>choice;


        float discount{};
        float cost;


        switch(choice){
            case 1: cout<<"Tickets cost $40\n";
                    cout<<"Enter number of tickets to purchase\n";
                    cin>>count;
                    cout<<"Enter amount\n";
                    cin>>amount;
                    cost = 40 * count;
                    if(amount < cost){
                        cout<<"The amount you entered is less\n";
                    }
                    else{
                        cout<<"Ticket(s) bought successfully\n";
                        if(count >= 5){
                            cout<<"You get a discount of 10% for purchasing more than 5 or more tickets!\n";
                            discount = 0.1;
                        }
                        cout<<"Here's your $"<< (amount - cost) + discount * (cost) <<" change\n";
                    }
            default: break;
        }
    }while(choice);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment