Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Coupon Application You work for a software company and you are asked to develop an app for a local coffee and donut shop. The app

Coupon Application

You work for a software company and you are asked to develop an app for a local coffee and donut shop. The app will process the retail transaction and will give the customer a credit every time they buy an item from the shop. After they earn a certain number of credits, the customer qualifies for a free donut.

The program should go through a loop for the series of these purchase transactions. The loop should keep asking the user thow many donuts they want to buy and then give them a credit for each donut they buy.

The program should keep track how many credits the customer have, as soon they reach 12 or more credits, the program should inform the user that they have enough credits to get a free donuts (12 credits = free donut) and prompt the user if they would like to use their credit to get a free donut. The customer has an option to use 12 credits toward a free donut. If they accept the free donut, the number of credits in their account will decrease by 12, and a single free donut will be given. If they decline to get a free donut, continue through the normal purchasing transaction allowing the customer to purchase more items and adding to the credits that the customer already has.

The main should provide the user the continual option to process a purchase or exit the program. So, the main loop has two choices:

  • P (Process a Purchase)

  • E (Exit Program)

Program Specification

Start the user credit balance at 0. Then enter the loop which starts by giving the user two choices at each pass (P or E), upper or lower case.

Every time the user chooses ‘P’, the program should check how many credits the customer has,

  • If there are fewer than the qualifying number ( set to 12), then a purchase transaction is executed.

  • If there are 12 or more credits in the customer account, then execute a free donut transaction .

Purchase Transaction

In the Purchase transaction sequence, ask the user how many items are being purchased, and add this number to the customer’s credit. At the end of the transaction, display to the screen the total and accumulated numbers of credit they have earned so far, including the current transaction.

Free-Donut Transaction

The Free-Donut Transaction should inform the user that they qualify for a free donut.

  • If the user accepts a free donut, inform them they have accepted a new donut, then deducted 12 credit from their account and display the reduced total number of credit available and end the transaction and move to the main loop menu.

    • The user is only allowed to get a free donut in a single transaction. For example, if the user has 20 credits, they can only get one donut in a single transaction and the new balance will be 20 – 12 = 8, allowing the user to get another free donut on the next transaction.

  • If the user decides not to take the free donut award, then the sequence of the program turns into the Purchase Transaction, in which the user can request to purchase one more item, and the corresponding number of credits is credited to their balance.

User Input Errors

  • Every time the user enters an error, cancel the transaction and proceed to the next loop pass (do not end the program). Do not attempt to keep the user in some sort of micro user-input loop, forcing them to stay within that transaction.

  • Always check if the user has entered invalid input like an invalid character choice or out of range number for the number of items being purchased. You program should not accept a 0 or more than 500 donut purchases.

  • One exception: When prompt the user for the number of donuts being purchased, assume they will always enter a numeric value. Do not check for a non-numeric error.

Test Run Requirements

Submit at least two runs that show everything. In each run, show several cycles (passes) of the loop. Use at least 6 purchase transactions and at least two free donuts along with the invalid inputs and make sure you demonstrate all options including one bad numeric input (out-of-range error).

Step by Step Solution

3.39 Rating (158 Votes )

There are 3 Steps involved in it

Step: 1

ANSWER Program import javautilScanner public class DonutShop public static void mainString args boolean repeat true Scanner input new ScannerSystemin ... 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

Recommended Textbook for

Business Research Methods

Authors: Donald R. Cooper, Pamela S. Schindler

12th edition

9780077774431, 0073521507, 77774434, 978-0073521503

More Books

Students also viewed these Operating System questions