Exercise02_26.java - import javax.swing.JOptionPane public...

This preview shows page 1 out of 1 page.

import javax.swing.JOptionPane; public class Exercise02_26 { // Main method public static void main(String[] args) { int amount; // Amount entered from the keyboard // Receive the amount entered from the keyboard String amountString = JOptionPane.showInputDialog( "Enter an amount in integer, for example 1156 \nfor 11 dollars and 56 cents"); // Convert string to double amount = Integer.parseInt(amountString); int remainingAmount = amount; // Find the number of one dollars int numOfOneDollars = remainingAmount / 100; remainingAmount = remainingAmount % 100; // Find the number of quaters in the remaining amount int numOfQuarters = remainingAmount / 25; remainingAmount = remainingAmount % 25;

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture