previous | start | next

File InputTest.java

1 import javax.swing.JOptionPane;
2
3 /**
4    This program tests input from an input dialog.
5 */
6 public class InputTest
7 {
8    public static void main(String[] args)
9    {
10       Purse myPurse = new Purse();
11
12       String input = JOptionPane.showInputDialog("How many nickels do you have?");
13       int count = Integer.parseInt(input);
14       myPurse.addNickels(count);
15
16       input = JOptionPane.showInputDialog("How many dimes do you have?");
17       count = Integer.parseInt(input);
18       myPurse.addDimes(count);
19
20       input = JOptionPane.showInputDialog("How many quarters do you have?");
21       count = Integer.parseInt(input);
22       myPurse.addQuarters(count);
23
24       double totalValue = myPurse.getTotal();
25       System.out.println("The total is " + totalValue);
26
27       System.exit(0);
28    }
29 }


previous | start | next