Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1: The Change Calculator: You are off to the candy store with a S5 bill to buy some candies. Write a program called ChangeCalculator

image text in transcribed

Question 1: The Change Calculator: You are off to the candy store with a S5 bill to buy some candies. Write a program called ChangeCalculator that allows you to enter the total cost of the candies that you are buying (ie., use the Scanner class) in cents (i.e., 127 cents is $1.27). The program should then tell you how many dollars, quarters, dimes, nickels and pennies that you should get as your change (assuming that you always pay with a S5 bill). Your program should return the least amount of coins possible. All your calculations should be in terms of cents so that you can use just int variables. Please handle exceptions nicely in your program. Your program should have nice-looking output as follows Enter the cost of the candies (in cents): 127 The change from $5.00 for $1.27 of candies is 3 dollar(s) 2 quarter(s) 2 dime(s) 0 nickel(s) 3 pennie(s) Notice that amount entered is an integer i.e., total cents) but the output statement displays the cost as a double (i.e., dollars). Test your code with the following costs 0, 25, 100, 101, 107, 150, 201, 235, 400, 498, 499, 500, 700

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

More Books

Students also viewed these Databases questions