📄 highestvalue.java
字号:
import java.io.*;
import javagently.*;
class HighestValue {
/* The Highest Value Program by J M Bishop Aug 1996
* ------------------------- Java 1.1 October 1997
* Java 2 and new Stream class
* May 2000
*
* Finds the highest in a list of numbers.
* Illustrates the if-statement
*/
HighestValue () throws IOException{
Stream in = new Stream (System.in);
System.out.println("***** Finding the highest number *****");
// Find out how many numbers will be coming
System.out.print("How many numbers (1 or more)?");
int n = in.readInt();
// Start off the sequence
System.out.println("Type them in");
System.out.print("1>");
int highest = in.readInt();
// Read and check the rest of the numbers
int number;
for (int i = 2; i <= n; i++) {
System.out.print(i+">");
number = in.readInt();
if (number > highest) {
highest = number;
}
}
System.out.println("That's enough, thanks");
System.out.println("The highest number was " + highest);
}
public static void main(String[] args) throws IOException {
new HighestValue ();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -