sentinels.java
来自「《A first book of java》by Gary J.Bronson 」· Java 代码 · 共 33 行
JAVA
33 行
import javax.swing.*;
public class Sentinels
{
public static void main(String[] args)
{
final double HIGHGRADE = 100.0;
String s1, outMessage;
double grade, total;
grade = 0;
total = 0;
outMessage = "To stop entering grades, type in any number"
+ "\n greater than 100.";
JOptionPane.showMessageDialog(null, outMessage,
"Program 5.8",
JOptionPane.INFORMATION_MESSAGE);
s1 = JOptionPane.showInputDialog("Enter a grade:");
grade = Double.parseDouble(s1);
while (grade <= HIGHGRADE)
{
total = total + grade;
s1 = JOptionPane.showInputDialog("Enter a grade:");
grade = Double.parseDouble(s1);
}
JOptionPane.showMessageDialog(null, "The total of the grades is " + total,
"Program 5.8",
JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?