Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The program below is supposed to ask the user to enter a dollar amount and then to enter with which bills and coins they pay

The program below is supposed to ask the user to enter a dollar amount and then to enter with which bills and coins they pay for the amount. The program then computes the amount to be given as cash back and the bills and coins to be used for that cash back amount.

I completed the previous part, and I still have / * Compute number of bills and coins * /, I want to know how to fix these problems

image text in transcribedimage text in transcribed

Cash.java Load default template... import java.util.Scanner; public class Cash { public static void main(String [] args) { Scanner scnr = new Scanner(System.in); double amount InDollars; int amountInCents; int num20DollarBills; int num10DollarBills; int num5DollarBills; int num1DollarBills; int numQuarters; int numDimes; int numNickels; int numPennies; int amountGivenInCents; int amountReturnInCents; int num20DollarBillsReturn; int num10DollarBillsReturn; int num5DollarBills Return; int num1Dollar Bills Return; int numQuartersReturn; int numDimesReturn; int numNickels Return; int numPennies Return; int amountCashBack; /* Ask the user to enter an amount in dollars and cents */ System.out.println("Please enter an amount in dollars and cents."); amountInDollars = scnr.nextDouble ; /* Convert dollar amount into amount in cents / amountInCents = (((int) amountInDollars) * 100); /* Ask the user to enter the number of bills they want to use */ System.out.println("How many $20 bills do you use to pay the amount?"); num20DollarBills = scnr.nextInt(); System.out.println("How many $10 bills do you use to pay the amount?"); num10DollarBills = scnr.nextInt(); System.out.println("How many $5 bills do you use to pay the amount?"); num5DollarBills = scnr.nextInt(); System.out.println("How many $1 bills do you use to pay the amount?"); num1 DollarBills = scnr.nextInt(); System.out.println("How many quarters do you use to pay the amount?"); numQuarters = scnr.nextInt(); System.out.println("How many dimes do you use to pay the amount?"); numDimes = scnr.nextInt(); System.out.println("How many nickels do you use to pay the amount?"); numNickels = scnr.nextInt(); System.out.println("How many pennies bills do you use to pay the amount?"); numPennies = scnr.nextInt ; /* Compute money given */ // TODO amountGiven InCents = scnr.nextInt(); /* Compute amount to return */ amountReturnInCents = amountGivenInCents - amountInCents; /* Compute number of bills and coins */ amountCashBack = amountReturnInCents; // TODO num20DollarBills = (26num10DollarBills); num10DollarBills = (2*num5DollarBills); num5DollarBills = (5*num 1DollarBills); num1 DollarBills = (4*numQuarters); numQuarters = (5*numNickels); numNickels = (5*numPennies); numDimes = (10%numPennies); amountInCents = numPennies ; /* Display information */ System.out.println("You must pay $" + amountInDollars); System.out.println("You gave $" + ((double) amountGivenInCents) / 100.0)); stem.out.println("There is $" + (((double) amountReturnInCents) / 100.0) + "cash back."); System.out.println("You are given " + num20DollarBillsReturn + " $20 bill(s), " + num10DollarBillsReturn + " $10 bill(s), " + num5DollarBills Return + " $5 bill(s), " + numlDollarBillsReturn + " $1 bill(s), " + numQuartersReturn + " Quarter(s), " + numDimesReturn + " Dime(s), " + numNickelsReturn + " Nickel(s) and " + Program errors displayed here Cash.java:78: error: variable num20DollarBillsReturn might not have been initialized num20DollarBillsReturn + " $20 bill(s), " + Cash.java:79: error: variable num10DollarBillsReturn might not have been initialized num10DollarBillsReturn + " $10 bill(s), " + Cash.java:80: error: variable num5DollarBillsReturn might not have been initialized num5DollarBillsReturn + " $5 bill(s), " + Cash.java:81: error: variable numlDollarBillsReturn might not have been initialized numlDollarBillsReturn + " $1 bill(s), " + Cash.java:82: error: variable numQuartersReturn might not have been initialized numquartersReturn + " Quarter (s), " + Cash.java:83: error: variable numDimesReturn might not have been initialized numDimesReturn + " Dime (s), " + Cash.java:84: error: variable numNickelsReturn might not have been initialized numNickelsReturn + " Nickel(s) and " + Cash.java:85: error: variable numPenniesReturn might not have been initialized numPenniesReturn + " Penny/ies."); 8 errors

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

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions