import java.util.Scanner;
//因為需要接收使用者輸入,因此因此import java.util.Scanner這個套件。
public class Lab{
public static void main(String args[]){
Scanner keyin = new Scanner(System.in);
System.out.println("score of chinese");
float chi = keyin.nextFloat();
System.out.println("score of English");
float eng = keyin.nextFloat();
System.out.println("score of Math");
float math = keyin.nextFloat();
float sum = (float)chi+eng+math;
float avg = sum/3.0F;
System.out.println("Yor score is "+sum+" and the avg is "+avg);
System.out.print("this semester is :");
System.out.println(avg>=60? "Passed!" : "Failed!");
//二擇一的情況可以不需要用到if/else敘述
}
}
//##### source code ends ###############
2009年1月14日 星期三
Java小練習(1)
1. 請設計一程式分別可以接受使用者輸入「國文、英文、數學」分數後,
將總分及平均顯示出來。
//######### source code starts from here #################
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言