Java: An Introduction to Problem Solving and Programming (7th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 2, Problem 5E

Explanation of Solution

Modified Program:

//include required header files

import java.util.Scanner;

//definition of "ChangeMaker" class

public class ChangeMaker

{

    //definition of main method

    public static void main(String[] args)

    {

        //declare the required variables

        int amount, originalAmount,

        quarters, dimes, nickels, pennies;

        int dollars, half_Dollars;

/*display the statements and get the input from the user*/

System.out.println("Enter a whole number greater than 0.");

System.out.println("I will find a combination of coins");

System.out.println("that equals that amount of change.");

        //create an object for scanner

        Scanner keyboard = new Scanner(System.in);

        amount = keyboard.nextInt();

        //assign the value

        originalAmount = amount;

        //compute dollar amount

        dollars = amount / 100;

        //calculate the amount

        amount = amount % 100;

        //compute half dollar amount

        half_Dollars = amount / 50;

        //calculate the amount

        amount = amount % 50;

        //compute quarters amount

        quarters = amount / 25;

        //calculate the amount

      ...

Blurred answer
Students have asked these similar questions
No AI solutions please
No AI solutions please
No AI solutions please

Chapter 2 Solutions

Java: An Introduction to Problem Solving and Programming (7th Edition)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
CMPTR
Computer Science
ISBN:9781337681872
Author:PINARD
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming Tutorial 36 - Intro to Loops; Author: Caleb Curry;https://www.youtube.com/watch?v=M3o7Y0juEP0;License: Standard YouTube License, CC-BY