Lab Assignment Objectives:
Understand the Application
You will obtain a grocery bill total from the customer. Depending on the amount of the grocery bill a coupon rewards amount will be calculated. The user will be informed of the amount of their earned customer rewards coupon.
The Program Specification
Your program will prompt the user for the cost of their groceries.
Then you are to calculate the value of the coupon to be awarded based on the amount of the grocery bill. Use the table below to determine coupon amounts.
Money Spent | Coupon Percentage |
Less than $10 | 0% |
From $10 to less than $60 | 8% |
From $60 to less than $150 | 10% |
From $150 to less than $210 | 12% |
From $210 or more | 14% |
Display an appropriate result message to the user including both the coupon percentage awarded and the dollar amount of their discount coupon.
Testing Requirements
Input Error Checking: You can assume that when it is time for the user to enter a number to represent the amount of his/her day’s grocery bill that a valid numeric value will be typed in. You do not need to test for non-numeric nor negative values. Note: A numeric 0 input is a valid data entry.
Be sure that your program runs correctly for each of these possible test cases: 0, 10, 70, 160, 222.
Here is a sample run (remember your program needs to work for all possible test case selections; your test run demonstration only needs to show one of the 5 possible test cases):
''' Please enter the cost of your groceries: 160 You win a discount coupon of $19.20. (12% of your purchase) '''
Tips and requirements:
Here is the code for your problem in PYTHON language
CODE :
NOTE : If you copy the code from answer , please remove comments and check if any dots added(this may occur while you copy) in a black background editor and check indentations twice.
#Creating variable for grocery_bills and asking user to enter bill amount print("Please enter the cost of your groceries: ") grocery_bill = float(input()) #NOTE : float(input()) will convert the bill to floating point #Creating variable for coupon amount , initially set to 0 coupon_amount = 0.00 #Printing result |
Please see the screenshots of the code below for indentations.(Python language is strict at indentations)
SCREENSHOTS
OUTPUT
Demonstrating output for the test case - bill amount = 160.
1.The user will enter the value of grocery bill as 160
2.Assuming the user entered valid numerical value(as you mentioned not to test for non-numeric and negative values)
it will be checked against the conditions given above.
3.As 160 is between 150 and less than 210 discount of 12% is calculated on the bill amount 160
4.Formula to calculate discount percentage
FORMULA : discount_amount = (bill amount) * (discount/100) |
Here , discount amount is the variable coupon-amount ,
bill amount is the variable grocery_bill,
discount is the variable discount.
For grocery_bill = 160.00
coupon_amount = (160)*(12/100) = 19.20
5.Displays finally the discount amount and discount percentage as
You win a discount coupon of $19.20(12% of your purchase)
OUTPUTS FOR ALL THE TEST CASES(0,10,70,160,222)
Lab Assignment Objectives: Translate a basic application statement into a software selection solution. Learn how to...
A supermarket awards coupons depending on how much a customer spends on groceries. For example, if you spend $50, you will get a coupon worth eight percent of that amount. The following table shows the percent used to caleculate the coupon awarded for different amounts spent. Write a program that calculates and prints the value of the coupon a person can receive based on groceries purchased. Here is a sample run: Please enter the cost of your groceries: 14 You...
Assignment #3 Introduction to C Programming-COP 3223 Objectives 1 Togve students practice at typing in, compiling and nunning simple programs. 2 To reinforce knowledge of assignment statements and arithmetic expressions 3. To learn how to use if statements for conditional execution Introduction: Programmers for a Better Tomorrow Programmers for a Better Tomorrow is an organization dedicated to helping charities, medical societies, and scholarship organizations manage various tasks so that they can focus on making the world a better place! They...
Part II – Cost Calculator (15 Points) A software company sells a package that retails for $ 99. Quantity discounts are given according to the following table: Quantity Discount 10 to 19 20% 20 to 49 30% 50 to 99 40% 100 or more 50% Write a program that asks the user to enter the number of packages purchased. The program should then display the discount percentage, amount of the discount (can be 0) and the total amount of the...
Assignment Overview This programming assignment is intended to demonstrate your knowledge of the following: Writing a while loop Writing a for loop Writing a while loop with a sentinel value Chocolate Coupons Foothill Fro-cho, LLC, gives customers a coupon every time they purchase a chocolate bar. After they earn a certain number of coupons, they qualify for a free chocolate bar, which they may use toward the purchase of a single chocolate bar. Usually, 7 is the...
PROGRAM STATEMENT AND REQUIREMENTS: Great Tutors Inc. is a company that provides tutoring services to elementary school students. Parents bring their students after school to their offices where one tutor is assigned to each student. The same tutor is assigned to the student for every visit. A tutor teaches his/her assigned student for several hours and charges a flat rate per hour for any student. Each tutor can only teach for a maximum of 40 hours. The program must ask...
For this lab you will write a Java program that plays the dice game High-Low. In this game a player places a bet on whether the sum of two dice will come up High (totaling 8 or higher), Low (totaling 6 or less) or Sevens (totaling exactly 7). If the player wins, they receive a payout based on the schedule given in the table below: Choice Payout ------ ------ High 1 x Wager Low 1 x Wager Sevens 4 x...
Java Program Note: no break statements or switch staements High, Low, Sevens For this lab you will write a Java program that plays the dice game High-Low. In this game a player places a bet on whether the sum of two dice will come up High (totaling 8 or higher), Low (totaling 6 or less) or Sevens (totaling exactly 7). If the player wins, they receive a payout based on the schedule given in the table below: Choice Payout ------...
Objectives: 1. Use if, switch, and loop statements 2. Use input and output statements 3. Incorporate functions to divide the program into smaller segments Instructions: Your task is to write a program that simulates a parking meter within the parking deck. The program will start by reading in the time a car arrives in the parking deck. It will then ask you what time the car left the parking deck. You should then calculate the time that has passed between...
I need help in C++ . Project 3 – Parking Deck Ticketing System Objectives: Use if, switch, and loop statements to solve a problem. Use input and output statements to model a real world application Incorporate functions to divide the program into smaller segments Instructions: Your task is to write a program that simulates a parking meter within the parking deck. The program will start by reading in the time a car arrives in the parking deck. It will then...
just the extra credit part please Your customer needs an automated system to patrol the highways. The job of the system is to collect the following information on vehicles traveling down a certain stretch of highway: license plate number, current speed, and speed limit. A program is required to determine if a speeding ticket is needed for each set of data. Ticket will only be issued when number of miles per hours (mph) over the speed limit is at least...