Loading...

Messages

Proposals

Stuck in your homework and missing deadline? Get urgent help in $10/Page with 24 hours deadline

Get Urgent Writing Help In Your Essays, Assignments, Homeworks, Dissertation, Thesis Or Coursework & Achieve A+ Grades.

Privacy Guaranteed - 100% Plagiarism Free Writing - Free Turnitin Report - Professional And Experienced Writers - 24/7 Online Support

Java program calculate change cashier

20/03/2021 Client: saad24vbs Deadline: 2 Day

Objectives:

arithmetic using integer and real (floating point) values,

use of integer division and integer remainder (% in Java) operators,

data type conversions (type casting),

decision making using if statements,

using methods to modularize programs, arguments/parameters for communication among methods (class level variables are not allowed in this assignment)

using some String class methods .charAt() .substring() .length()

using Math.round.

The scenario

Your friend Joe the Cashier works the graveyard shift at the local convenience store. His cash register tells him how much change he needs to return to his customer, but he is having trouble figuring out what bills and coins to give to the customer to make up the change due. You have agreed to write a Change Maker program for him. The requirements of this program are discussed below.

Input Data

There is only one item of input data: The change due to the customer. This will be a dollars and cents figure, expressed as a decimal fraction, such as 37.67. This will be stored in a variable of type double.

Output

The output will contain the number of each type of bill and coin to be given to the customer. Some of these numbers could be 0 and those would be omitted from the output. Here is a sample interaction between the program and the user:

image1.jpg

Assumptions

We assume that the register contains an ample supply of bills ($20, $10, $5, $1) and coins (quarters, dimes, nickels, pennies) so we can always make up the change due using fewest number of bills and coins. We further assume that $20 is the largest denomination that we will use.

Strategy to solve this problem

First we need the whole numbers of dollars and cents from the real number (that may contain a decimal fraction) representing the change due. So from 37.67 we need to get 37 and 67. A real value can be assigned to an integer

variable (using a cast operator) to extract the whole number part of the real value. The difference between the real value and the whole number part can be multiplied by 100 (round the difference to nearest int) to get the total number of cents. Now we work with the dollars and the cents figures separately. We work from larger to smaller denominations.

We can use a variable to keep track of how many dollars (cents) has not yet been accounted for by the bills (coins) the program has decided to use for change making. I give an example of how the calculation could proceed.

Initially, we have 37 dollars to make change for.

Decide how many $20 bills we need. 37/20 = 1, so we need 1 $20 bill. 37%20 = 17, so we still need to make change for 17 dollars.

Decide how many $10 bills we need. 17/10 = 1, so we need 1 $10 bill. 17%10 = 7, so we still need to make change for 7 dollars.

Decide how many $5 bills we need. 7/5 = 1, so we need 1 $5 bill. 7%5 = 2, so we still need to make change for 2 dollars.

The number of dollars left over at this stage is the number of $1 bills we need.

The numbers of coins of various denominations can be calculated in a similar way.

Nicknames for the bills

The bills are often referred to by the names of the Historical Persons whose pictures appear on them. So a $20 bill is called a Jackson, $10 -- Hamilton, $5 – Lincoln, $1 – Washington.

Singular and plural forms of the bill and coin names

The plural form of all the coin/bill names (except "Penny" used for 1¢ coin) can be formed by just adding an 's' to the singular form. But the coin name "Penny", has the plural "Pennies". This is handled by checking if the last character in the name is 'y'. If not, just concatenate an 's' to the end of the singular name to form the plural. Otherwise, form a substring by removing the 'y' and add "ies" to that substring to form the plural. We will handle this by defining a method that gives us the plural form from the singular. The output should use the plural form of the bill/coin names when appropriate.

Program organization

The program is to be written using several methods in addition to the "main" method.

main –This method prints the sign-on message and describes its purpose. It then prompts the user to enter the change due as a double value and accepts the input into a double variable (no validation necessary). It then calculates two integer values (dollars and cents in the change due). It then calls the methods showDollars and showCents with appropriate arguments. Finally it prints the sign-off message.

void showDollars(int) – This method accepts an int parameter representing the whole number of dollars in the change due. It calculates the numbers of bills of various denominations to be returned and call the last method to print the number and the name for each denomination of bills used.

void showCents(int) – This method is similar to the method above but it deals with the coins to be returned, so it receives a parameter representing the cents part of the change due.

void showNumberAndName(int, String) – This method receives a number of a particular bill/coin and the name of that bill/coin as part of returned change. If the number is 0, this method returns without producing any output. If the number is 1 then it prints 1 followed by the name. If the number is > 1 then it prints the number followed by the plural form of the name.

String plural(String) – This method returns the paramete

Homework is Completed By:

Writer Writer Name Amount Client Comments & Rating
Instant Homework Helper

ONLINE

Instant Homework Helper

$36

She helped me in last minute in a very reasonable price. She is a lifesaver, I got A+ grade in my homework, I will surely hire her again for my next assignments, Thumbs Up!

Order & Get This Solution Within 3 Hours in $25/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 3 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 6 Hours in $20/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 6 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 12 Hours in $15/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 12 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

6 writers have sent their proposals to do this homework:

Top Quality Assignments
Coursework Help Online
Top Essay Tutor
A+GRADE HELPER
Solution Provider
Professional Coursework Help
Writer Writer Name Offer Chat
Top Quality Assignments

ONLINE

Top Quality Assignments

Hello, I an ranked top 10 freelancers in academic and contents writing. I can write and updated your personal statement with great quality and free of plagiarism

$29 Chat With Writer
Coursework Help Online

ONLINE

Coursework Help Online

Give me a chance, i will do this with my best efforts

$112 Chat With Writer
Top Essay Tutor

ONLINE

Top Essay Tutor

Hello, I an ranked top 10 freelancers in academic and contents writing. I can write and updated your personal statement with great quality and free of plagiarism

$102 Chat With Writer
A+GRADE HELPER

ONLINE

A+GRADE HELPER

Hello, I an ranked top 10 freelancers in academic and contents writing. I can write and updated your personal statement with great quality and free of plagiarism

$71 Chat With Writer
Solution Provider

ONLINE

Solution Provider

You can award me any time as I am ready to start your project curiously. Waiting for your positive response. Thank you!

$18 Chat With Writer
Professional Coursework Help

ONLINE

Professional Coursework Help

Hello, I an ranked top 10 freelancers in academic and contents writing. I can write and updated your personal statement with great quality and free of plagiarism

$102 Chat With Writer

Let our expert academic writers to help you in achieving a+ grades in your homework, assignment, quiz or exam.

Similar Homework Questions

Red bus timetable central coast - Describe homo erectus's cranial and postcranial anatomical characteristics - Chapter 10 measuring exposure to exchange rate fluctuations - P8#1 and P8#2 - Letter of intent as an educator gcu - How to create a healthy workplace environment presentation - Cedrus deodara divinely blue - Ilana industries inc needs a new lathe - Dean woodcock neuropsychological battery dwnb houghton mifflin harcourt - A push pull twist - Raymarine s100 remote control - What does non discriminatory use of language mean - Hidden intellectualism by gerald graff they say i say - How to use revtex - Climate Change Report_NEED in 6 HOURS - Cell city phone specials - Low carb lasagne sheets coles - Research topic and write - Learning outside the classroom manifesto summary - How are faults hypocenters and epicenters related - Debate on mobile phones should not be allowed in school - Digital marketing - Prepare a classified balance sheet as of december 31 2018 - John f kennedy's inaugural speech pdf - Parsons sick role theory - 5 second rule game rules pdf - Investment analysis - Evergreen company sells lawn and garden products to wholesalers - Doctrine of caveat emptor ppt - The qualities of the prince - Phenyl oxalate and fluorescent dye solution - Ib chemistry topic 3 - Animal farm important quotes - A company manufacturing oil seals wants to establish - Vitodens 200 wb2b manual - Hofstra university transcript request - BUS 5115 UNIT 2 - Shadow health focused exam abdominal pain - Mykbs - Rules to write a sonnet - COMPLEX REPORT - The psychodynamics of social networking - 5a capper place kardinya - Steam at 320 c flows in a stainless - Organizational structure of csu - Push pull workout pdf - Chapter 8 reporting and analyzing receivables - Poustinia christian spirituality of the east for western man - The art and science of leadership nahavandi pdf - AUTHENTIC LEADERSHIP - Rolling wave planning example - Kennedy betta electrical cairns - Electron dot diagram worksheet with answers - Use hygienic practices for food safety answers - Computer science made simple - 0.375 as a fraction simplified - What it means to say phoenix arizona summary - Organisational theory - Extreme close up effect on audience - MATH PROBLEM SET - Campus fitness center excel - Worship coordinator job description - BUS 322 Week 3 Assignment 1 What Makes ____ the Best Place to Work and Why? - Human Services Organizations as systems - The role of media in influencing government and the public - Her three days short story - Statutory reporting requirements australia - How to find side length of non right triangle - First isomorphism theorem for modules proof - DISCUSSION #3 - Fetal pig spinal cord diagram - Third grade spelling list - 19th century prime ministers - 0x80041003 wmi access denied - Barclays internet banking bib - Healthcare Finance - Food hygiene level 2 answers - Ucumberlands blackboard - Ws 5.4 ideal gas law answers - LEGALIZATION OF DRUGS - Managerial Economics - Industry report and company report - M 5 ib - 3rd degree heart block acls - Risks commonly considered to understand project financing are: - 1.26 g cm3 to kg m3 - The town hall meeting was desultory because - Choosing a mixed methods design - Quality tactics and the logistics and supply chain functions - Linda albert cooperative discipline quotes - Discussion - University of phoenix marketing strategy - Corporate social responsibility tutor2u - Dollargeneral com payroll - Week 6 lab summit ridge mountain resort student - Qflow front load washing machine - Phet colorado magnets and compass - How to write algorithm and flowchart for c program - Mansfield opticians wells somerset - COURSE PROJECT -PART 2 - Peer Review