Description
The purpose of this challenge is to employ the use of basic functions. This challenge creates a simple tip calculator as would be used in a restaurant.
Requirements
- Create a function that accepts two numeric parameters and returns a numeric. See the prototype below:
double calc_tip(double bill_amt, double rating);
- The calc_tip() function will calculate the tip on bill_amt as follows: If the rating is 0, then the tip is zero. If the rating is greater than 0, but less than or equal to 4, then the tip is 5% of the bill amount. If the rating is greater than 4, but less than or equal to 7, then the tip is 15% of the bill amount. If the rating is greater than 7, then the tip is 20% of the bill amount.
- Make sure that the calc_tip() function does not request user input or display any messages. The calc_tip() function should only perform a calculation.
- In main, ask the user to input values for bill amount and the rating.
- Display the calculated tip amount.
Sample Interaction / Output
What is the bill amount? 100.00 How do you rate the service? 5 Great! You should tip $15.00
What is the bill amount? 100.00 How do you rate the service? 8 Great! You should tip $20.00
What is the bill amount? 100.00 How do you rate the service? 0 That bad? You should tip $0.00
LEGEND
PROGRAM OUTPUT
USER INPUT
FROM INPUT
CATALOG ID: CPP-CHAL0003
Print Requirements