Answer to Question #250787 in C++ for Fisiwe Shezi

Question #250787

NuMetro has a special on movies for all members of the public but special discounts for students and pensioners. If

pensioners or students buy a movie ticket they receive 10% if they buy a movie and popcorns, they receive 20%

discount. Other customers only receive a discount when they buy a movie ticket and popcorn; there is no discount for

just a movie ticket alone.

Write a program named question5b.cpp that will consist of two functions. The program must prompt the user for type of

customer (‘p’ for pensioner, ‘s’ for student, ‘o’ for other). It must then call the relevant function according to that entry.

The first function must receive the customer type and calculates discount for pensioners and students. The second

function calculates the discount for customers that are not pensioners or students.


1
Expert's answer
2021-10-13T06:25:12-0400
#include<iostream>
using namespace std;
double pensioners_student_ticket(){
	double total;
	char c;
	cout<<"Do you want to buy popcorns (y/n)?";
	cin>>c;
	if(c=='y'){
		total = 80 - (0.2 * 80);
	}
	else{
		total = 80 - (0.1 * 80);
	}
	return total;
}


double other_customers(){
	double total;
	char c;
	cout<<"Do you want to buy popcorns (y/n)?";
	cin>>c;
	
	if(c=='y'){
		total = 80 - (0.05 * 80);
	}
	else{
		total = 80;
	}
	return total;
}


int main(){
	cout<<"Enter user type:  customer ('p' for pensioner,'s' for student, 'o' for other)\n";
	char type;
	cin>>type;
	if(type=='p'|| type=='s'){
		cout<<"The final amount that is due for the movie ticket is:  "<<pensioners_student_ticket()<<endl;
	}
	else if(type=='o'){
		cout<<"The final amount that is due for the movie ticket is:  "<<other_customers()<<endl;
	}
}

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

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS