Question: Create a class that calculates and displays the conversion of an entered number of dollars into currency denominations - 100s, 50s, 20s, 10s, 5s, and
Create a class that calculates and displays the conversion of an entered number of dollars into currency denominations - 100s, 50s, 20s, 10s, 5s, and 1s. Obtain all inputs and display all outputs using dialog boxes. Save the class as Dollars.Java.
Code Example:
import javax.swing.*;
public class Test{
public static void main(String [] args){
double dblInput = 0.0; int intInput = 0; String rawInput;
rawInput = JOptionPane.showInputDialog(null, "Please enter a double value. Example: 33.44"); dblInput = Double.parseDouble(rawInput); System.out.println("The value entered is: " + dblInput);
rawInput = JOptionPane.showInputDialog(null, "Please enter an int value. Example 231"); intInput = Integer.parseInt(rawInput); System.out.println("The value entered is: " + intInput);
System.exit(0); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
