Lab If-Else (2)
import javax.swing.JOptionPane;
public class LabIfElse2 {
public LabIfElse2() {
}
public static void main(String[] args) {
double net,fivePercentTax, tenPercentTax;
String tax;
String netIcome = JOptionPane.showInputDialog("Enter a number :");
net = Double.parseDouble(netIcome);
if (net <= 0)
tax = "n < 0";
else if ((net >= 0) && (net <= 100))
tax = "0 <= n <100";
else
{
tax = "n >= 100";
}
JOptionPane.showMessageDialog(null,"Ans: "+ tax);
System.out.println( tax );
System.exit(0);
}
}
0 Comments:
張貼留言
<< Home