Exercise 4: Write a program that reads how much a customer spends on groceries and computes the discount coupon that a customer will be awarded. The following table shows the percent used to calculate the coupon awarded for different amounts spent. Your program should calculate and print the value of the coupon a person can receive based on groceries purchased. The program should display the message "Error: negative cost" if user enters a negative groceries cost. Money Spent Less than $10 From $10 to $60 More than $60 to $150 Coupon Percentage No coupon 8% 10% More than $150 to $210 12% More than $210 14% Please enter the cost of your groceries: 14 You won a discount coupon of $ 1.12. (8% of your purchase) Figure 5: Sample run of Exercise 4

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter3: Input/output
Section: Chapter Questions
Problem 4PE: 4. During each summer, John and Jessica grow vegetables in their backyard and buy seeds and...
icon
Related questions
Question
Write a problem, input, output , algorithm,comments and design a python program
Exercise 4:
Write a program that reads how much a customer spends on groceries and computes the discount coupon
that a customer will be awarded. The following table shows the percent used to calculate the coupon
awarded for different amounts spent. Your program should calculate and print the value of the coupon a
person can receive based on groceries purchased. The program should display the message "Error: negative
cost" if user enters a negative groceries cost.
Money Spent
Less than $10
Coupon Percentage
No coupon
From $10 to $60
8%
More than $60 to $150
10%
More than $150 to $210
12%
More than $210
14%
Please enter the cost of your groceries: 14
You won a discount coupon of $ 1.12.
(8% of your purchase)
Figure 5: Sample run of Exercise 4
Transcribed Image Text:Exercise 4: Write a program that reads how much a customer spends on groceries and computes the discount coupon that a customer will be awarded. The following table shows the percent used to calculate the coupon awarded for different amounts spent. Your program should calculate and print the value of the coupon a person can receive based on groceries purchased. The program should display the message "Error: negative cost" if user enters a negative groceries cost. Money Spent Less than $10 Coupon Percentage No coupon From $10 to $60 8% More than $60 to $150 10% More than $150 to $210 12% More than $210 14% Please enter the cost of your groceries: 14 You won a discount coupon of $ 1.12. (8% of your purchase) Figure 5: Sample run of Exercise 4
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage