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 More than $60 to $150 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)

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 11PE
icon
Related questions
Question
Write a problem, input, output, algorithm,comments and design a 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 7 images

Blurred answer
Knowledge Booster
Module hierarchy chart
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
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
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT