Question
Cash Register Programming challenge description: The goal of this challenge is to design a cash register program. You will be given two decimal numbers. The
Cash Register
Programming challenge description:
The goal of this challenge is to design a cash register program. You will be given two decimal numbers. The first is the purchase price (PP) of the item. The second is the cash (CH) given by the customer. Your register currently has the following bills/coins within it: 'PENNY': .01, 'NICKEL': .05, 'DIME': .10, 'QUARTER': .25, 'HALF DOLLAR': .50, 'ONE': 1.00, 'TWO': 2.00, 'FIVE': 5.00, 'TEN': 10.00, 'TWENTY': 20.00, 'FIFTY': 50.00, 'ONE HUNDRED': 100.00 The aim of the program is to calculate the change that has to be returned to the customer.
Input:
Your program should read lines of text from standard input. Each line contains two numbers which are separated by a semicolon. The first is the Purchase price (PP) and the second is the cash(CH) given by the customer.
Output:
For each line of input print a single line to standard output which is the change to be returned to the customer. In case the CH < PP, print out ERROR. If CH == PP, print out ZERO. For all other cases print the amount that needs to be returned, in terms of the currency values provided. The output should be alphabetically sorted.| Test Case #1: Input: 15.94;16.00 Output: NICKEL,PENNY Test Case #2: Input: 17;16 Output: ERROR Test Case #3: Input: 35;35 Output: ZERO Test Case #4: Input: 45;50 Output: FIVE Python Code Example: import sys for line in sys.stdin: print(line, end="") Java Example Code: public class Main { /** * Iterate through each line of input. */ public static void main(String[] args) throws IOException { InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8); BufferedReader in = new BufferedReader(reader); String line; while ((line = in.readLine()) != null) { System.out.println(line); } } }
Criteria For Solution And Thumbs Up: -PLEASE USE THE EXAMPLE CODE PROVIDED BELOW -PLEASE SOLVE USING JAVA AND PYTHON 3 -WRITE A FULLY ANSWERED, OPTIMIZED, AND DETAILED CODE WITH COMMENTS AND SCREENSHOTS OF CODE AND OUTPUT -WRITE A FULLY EXPLAINED APPROACH ON HOW TO SOLVE IT AND WHY THAT APPROACH -TIME/SPACE COMPLEXITY ALONG WITH THE WHY -ALL TEST CASES MUST PASS
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started