Write the pseudocode for a program that will calculate the cost of a ticket orde
ID: 3598737 • Letter: W
Question
Write the pseudocode for a program that will calculate the cost of a ticket order for a Downtown Stadium and display the receipt for the customer on the screen. There are 2 ticket prices: adult, and senior citizen. Adult seats are $4.50 and senior citizen seats are $3.50. If more than 5 tickets are purchased, the customer gets an extra 20% off the of the ticket order. If more than 10 regular seats are purchased, the customer gets an additional 10% off the cost of the order. A customer can only place an order for one type of ticket. Output the type of ticket purchased, the number of tickets purchased, the gross cost, the amount of the discount, and the final cost of the order.
Explanation / Answer
Here is the C++ Code .
#include<iostream>
#include<cstdlib>
using namespace std ;
int main()
{
int n ;
int ad , sc ;
cout << "Enter the number of customers ";
cin >> n ;
cout<<"Enter the number of adults ";
cin >> ad;
cout << "Enter the number of senior citizens ";
cin >> sc;
int total;
float gross_cost , discount , final_cost ;
float gross_cost1 , discount1 , final_cost1 ;
float gross_cost2 , discount2 , final_cost2 ;
total=sc+ad;
if(ad==0||sc==0)
{
//it means only one type of customers are there so he can get these tickets
if(total>5&&total<10)
{
gross_cost = ad*4.5 + sc*3.5;
discount= gross_cost*0.20;
final_cost=gross_cost- discount;
cout <<"Purchased tickets are "<<total<<endl;
cout <<"Gross amount is "<<gross_cost<<endl;
cout<<"Discount is "<<discount<<endl;
cout<<"Final cost is "<<final_cost<<endl;
exit(0);
}
else if(total>=10)//more than 10
{
gross_cost = ad*4.5 + sc*3.5;
discount= gross_cost*0.30;//10 % extra
final_cost=gross_cost- discount;
cout <<"Purchased tickets are "<<total<<endl;
cout <<"Gross amount is "<<gross_cost<<endl;
cout<<"Discount is "<<discount<<endl;
cout<<"Final cost is "<<final_cost<<endl;
exit(0);
}
}
if(sc>=5&&sc<10)
{
gross_cost1 = sc*3.5;
discount1= gross_cost1*0.20;
final_cost1=gross_cost1- discount1;
}
else if (sc>=10)
{
gross_cost1 = sc*3.5;
discount1= gross_cost1*0.20;
final_cost1=gross_cost1- discount1;
}
else
{
gross_cost1 = sc*3.5;
discount1= 0;
final_cost1=gross_cost1;
}
if(ad>=5&&ad<10)
{
gross_cost2 = ad*4.5 ;
discount2= gross_cost2*0.20;
final_cost2=gross_cost2- discount2;
}
else if (ad>=10)
{
gross_cost2 = ad*4.5;
discount2= gross_cost2*0.20;
final_cost2=gross_cost2- discount2;
}
else
{
gross_cost2 = ad*4.5;
discount2= 0;
final_cost2=gross_cost2;
}
gross_cost=gross_cost1+gross_cost2;
discount=discount1+discount2;
final_cost=final_cost1+final_cost2;
cout <<"Purchased tickets are "<<total<<endl;
cout <<"Gross amount is "<<gross_cost<<endl;
cout<<"Discount is "<<discount<<endl;
cout<<"Final cost is "<<final_cost<<endl;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.