Monday, March 20, 2006

Lab 5







package s9226307;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class s9226307{
public s9226307(){
}
public static void main(String[] args)throws IOException
{
BufferedReader keyboard= new BufferedReader(new InputStreamReader(System.in));
System.out.println("輸入十個數字:");
System.out.println("我選擇最大的.");
double max=-1,min=-1,num=0;
int n;
String input="";
for(n=1;n<=10;n++) { input = keyboard.readLine(); num = Double.parseDouble(input); if (num>=max)
max = num;
if(num<=min)
min = num;

}
System.out.println("最大數字是 "+max);
}
}

0 Comments:

Post a Comment

<< Home