Please don't copy and paste Write a C++ program that includes a function to calculate the discount applicable on the pri

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Please don't copy and paste Write a C++ program that includes a function to calculate the discount applicable on the pri

Post by answerhappygod »

Please don't copy and paste
Write a C++ program that includes a function to calculate thediscount applicable on the price of an item. Your function shouldhave three arguments: the price as a reference parameter to adouble, the discount as a double value, and a bool to indicate ifthe discount is calculated as a percentage or a fixed amount. Callthe parameter to indicate whether the discount is a fixed amount,or a percentage, fixed. When fixed is true, it will indicate thatthe discount is a fixed amount and when it is false, the discountis a percentage. Your function should calculate the discount andmodify the price of the item accordingly.Your function should check that the discount is not negative andthat the price does not drop to zero or below zero after applyingthe discount. Use the assert() function to ensure that the discountis not negative and that the price does not drop to zero or belowzero once the discount is applied.Test you program with the following input, and submit the outputfor all the cases:235.97 7.35 false5430.55 120.00 true856.00 -12.5 false120.00 130.00 trueNB: Note that you are expected to use the assert macro in thisquestion.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply