Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The On the Go family super market is giving discounts for their customers who shop between 16:00 to 22:00 hrs. The discounts are given according

image text in transcribed

The "On the Go" family super market is giving discounts for their customers who shop between 16:00 to 22:00 hrs. The discounts are given according to the time and the amount they spend at the shop. The discount percentages are shown in the following table. a) Write a function called calDiscount ( ) to calculate the discount given for a transaction by sending the time as and integer ( eg : between 16:00 to 16:59 enter only 16 ) and the total amount as parameters. float caldiscount (int time, float totAmount) b) Write a function called testCaldiscount ( ) which contains two assert statements debug the above implemented function. The supermarket has also decided to give a free gift for the customers according to the amount after deducting the discount. The table below shows the criteria for the gifts. c) Write a function called displaygift ( ) to display the gifts obtained by each customer. void displayGift(float finalTot) d) In your main program do the following : i. Call the testcaldiscount( ) function. ii. Input the time and the total amount from keyboard. If the user enters an invalid time then display an error message. Display the final amount(after discount) and the gift obtained using the two functions implemented in part a) and part c)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions