Write a program on ticket purchasing discount in cinemal hall
#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;
}
Comments
Leave a comment