Question

In: Computer Science

C++ programming: FUNCTIONS WITH DIFFERENT RETURN TYPES AND PARAMETERS NuMetro has a special on movies for...

C++ programming: FUNCTIONS WITH DIFFERENT RETURN TYPES AND PARAMETERS

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.

Solutions

Expert Solution

cpp code:

#include <iostream>

using namespace std;

//function 1 for pensioner and student
int discountType1(char popCorn)
{
//if popcorn, discount 20
if(popCorn=='y')
return 20;
else
return 10; //else 10
}
//function 2 for others
int discountType2(char popCorn)
{
//if popcorn, discount 20
if(popCorn=='y')
return 20;
else
return 0; //else 0
}
int main()
{
char type,c;

//prompt for user type
cout << "Enter the of customer ('p' for pensioner, 's' for student, 'o' for other): ";
cin>>type;
//popcorn
cout<<"\nWant pop corn ('y' /'n'): ";
cin>>c;

//call the function
if(type=='p' || type=='s')
cout<<"\nYou got discount of "<<discountType1(c)<<" %\n";
else
cout<<"\nYou got discount of "<<discountType2(c)<<" %\n";


return 0;
}

output:

//for any clarification , please do comments, if you found this solution useful,please give me thumbs up


Related Solutions

Do movies of different types have different rates of return on their budgets? The response variable:...
Do movies of different types have different rates of return on their budgets? The response variable: US Gross( $M) Explanatory variable:   Budget ( $M) Categorical variable :  Type of movie : Comedy =1 ; Action Picture =0. Using the regression output with an indicator variable: MODEL 1: Summary of Fit RSquare 0.318 RSquare Adj 0.338 Root Mean Square Error 46.50 Mean of Response Number of observations 58 Parameter Estimates Term Estimate Std Error t Ratio Prob>|t| Intercept -7.03913 16.20 -0.435 0.6655* Budget(...
// If you modify any of the given code, the return types, or the parameters, you...
// If you modify any of the given code, the return types, or the parameters, you risk getting compile error. // You are not allowed to modify main (). // You can use string library functions. #include <stdio.h> #include <stdlib.h> #include <string.h> #pragma warning(disable: 4996) // for Visual Studio #define MAX_NAME 30 // global linked list 'list' contains the list of employees struct employeeList {    struct employee* employee;    struct employeeList* next; } *list = NULL;              ...
This program should be designed in group. Divide by classes. Parameters and return types of each...
This program should be designed in group. Divide by classes. Parameters and return types of each function and class member function should be decided in advance. Write a program that computes a patient's bill for a hospital stay. The different components are: PatientAccount Class Surgery Class Pharmacy Class main program Patient Account will keep total of the patient's charges. Keep track of the number of days spent in the hospital. Group must decide on hospital's daily rate. Surgery class will...
Modeling with Functions In this course you have learned the characteristics of different types of functions...
Modeling with Functions In this course you have learned the characteristics of different types of functions and have practiced solving application problems involving modeling with these functions. For each scenario below, decide what type of function would best model the situation. Explain why you chose that type of function. Show your work in writing the function to model the situation. Be sure to state what the independent variable represents. Then use your model to answer the questions for that scenario....
Which ways can you change the values of parameters inside the function in C programming?
Which ways can you change the values of parameters inside the function in C programming?
c++120 Holideals at the Movies! We have special movie tickets on holidays! Prices are discounted when...
c++120 Holideals at the Movies! We have special movie tickets on holidays! Prices are discounted when you buy a pair of tickets. Create a program for the HoliDeals event that computes the subtotal for a pair of tickets. The program should ask the the ages of the first and second guests to compute the price. There are different pricing structures based on the guests' age. Children tickets cost $10 (age below 13) Young Adult tickets cost $13 (age below 21)...
Divide by classes. Parameters and return types of each function and class member function should be...
Divide by classes. Parameters and return types of each function and class member function should be decided in advance. Write a program that computes a patient's bill for a hospital stay. The different components are: PatientAccount Class Surgery Class Pharmacy Class main program Patient Account will keep total of the patient's charges. Keep track of the number of days spent in the hospital. Group must decide on hospital's daily rate. Surgery class will have stored within it the charges for...
Using C++ programming. Thank you. Money class has the following member variables and functions. -member variable...
Using C++ programming. Thank you. Money class has the following member variables and functions. -member variable : dollar, cent -member function : setMoney(int dollar, int cent), printMoney(), operator overloading(+) Program the Money class so that the following function can be performed. int main(){ Money a, b, c; A.setMoney(10, 60); B.setMoney(20, 70; (a+b).printMoney(); c = a + b; c.printMoney(); }
In Object Oriented programming C++ : Write the appropriate functions for Student to neatly display a...
In Object Oriented programming C++ : Write the appropriate functions for Student to neatly display a Student, and then finally GPA. Have items neatly line up in columns. I need help creating a derived class called student that finds GPA (between 0.0 and 4.0) and credits completed (between 0 and 199).
in phyton programming: with numpy Create a function called biochild.  The function has as parameters...
in phyton programming: with numpy Create a function called biochild.  The function has as parameters the number m and the lists ??????h?? and ??????h??.  The lists ??????h?? and ??????h?? contain 0’s and 1’s.  For example: ??????h?? = [1,0,0,1,0,1] and ??????h?? = [1,1,1,0,0,1]  Both lists have the same length ?.  The 0's and 1's represent bits of information (remember that a bit is 0 or 1).  The function has to generate a new list (child)....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT