Question: the code worked before I tried to add the do-while loop since this is a mod for it. But now it's saying it's out of

the code worked before I tried to add the do-while loop since this is a mod for it. But now it's saying it's out of bound after I enter how much change

the question is Modify the ChangeMaker program you wrote last week by adding a do while loop to check if they want to calculate more change.

``` import java.util.Scanner;

public class ChangeMakerMod { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); //the function int change, remChange, quarters, dimes, nickels, pennies; char repeat; String input; do { // Take input as the change System.out.print("How much change do you want to make?" + "Enter in the number from 1 to 99 "); change = keyboard.nextInt(); remChange = change;

// Calc the quarters and remaining change quarters = remChange/ 25; remChange = remChange%25;

// Calc the dimes and remaining change dimes = remChange/ 10; remChange = remChange %10;

// Calc the nickels and remaining change nickels = remChange/ 5; remChange = remChange % 5;

// Calc the pennies pennies = remChange; //ask if the user want to add more change System.out.println("Would you like to enter more change?"); System.out.println("Enter Y for yes, N for no"); input=keyboard.nextLine(); repeat=input.charAt(0); } while(repeat== 'Y' || repeat== 'y'); // Display the change amount and number of different coins System.out.println("You have entered " + change + " cents for change which is " + quarters + " quarters, " + dimes + " dimes, " + nickels + " nickels, " + pennies + " pennies.");enter code here }

} ```

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!