COMP2243 - Programming and Problem Solving

Syllabus Software Installation Assignments Tests
Lectures and Labs
**Back to Full Menu**

Fundamentals HelloWorld.java Basics.java Payroll.java Cartons.java Time.java DollarAmount.java StringPractice.java PayrollGUI.java



DollarAmount Program


Description

The purpose of this program is to input the purchase amount and cash paid, then calculate the change and figure out the change in quarters, dimes, nickels, and pennies.

Associated Concepts:

Division operator / and modulus operator %

Math.round() method

Algorithm:

Declare variables to store data items

Read data for purchase amount and cash paid

Calculate the change

Use division operator / and modulus operator % to figure out the change in quarters, dimes, nickels, and pennies.

Hint: Use Math.round() method to get the accurate amount

Print the result

Source Code



Sample Run



Video