import javax.swing.JOptionPane; /** * A class to give students practice using the single-alternative and * two-alternative forms of the "if" statement * * @author Greg */ public class DecisionTester { public static void main(String[] args) { // Exercise 1: The following code reads an int and prints it. // Use a SINGLE_ALTERNATIVE "if" statement that converts a negative // number to positive String input = JOptionPane.showInputDialog("Enter an int") ; int number = Integer.parseInt(input) ; // insert if statement here System.out.println("The number is " + number); JOptionPane.showMessageDialog(null,"press OK to continue") ; // Exercise 2: American Veeblefetzer, Inc awards salespersons who have // more than $10000 in sales with a bonus of 10% of sales. Salespersons // who do not meet that amount get only a 5% bonus. // Use a TWO-ALTERNATIVE "if" statement to compute the bonus double bonus = 0.0 ; input = JOptionPane.showInputDialog("Enter total sales") ; double sales = Double.parseDouble(input) ; // insert if statement here System.out.printf("%nFor sales of $%.2f the bonus is $%.2f%n" , sales, bonus); System.exit(0); } }