// Step #1
import javax.swing.*;
public class InputExample2 {
public static void main(String[] args) {
// Step #2 : Declare a variable to store the input
String inputStr;
// Step #3: Prompt the user
inputStr = JOptionPane.showInputDialog(null,
"What is your hourly salary?");
// Step #4: Convert String to double
double salary = Double.parseDouble(inputStr);
// Step #5: Display results
double result = salary*8;
JOptionPane.showMessageDialog(null,
"You earn $" + result +
" per day");
} //end main
} //end class
Tuesday, October 03, 2006
Input Example 2: double input
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment