標題:
4/20隨堂測驗
[打印本頁]
作者:
顏子翔
時間:
2019-4-20 14:56
標題:
4/20隨堂測驗
今天測驗502唷,請各位回覆測驗答案
作者:
彭煥宇
時間:
2019-4-20 15:00
import java.util.Scanner;
public class JPA05 {
public static Scanner keyboard = new Scanner(System.in);
public static void main(String args[]) {
float sum=0f;
System.out.print("請輸入學生人數:");
int num=keyboard.nextInt();
float score[]=new float[num];
for(int i=0; i<score.length; i++)
{
System.out.print("第"+(i+1)+"個學生的成績: ");
score[i]=keyboard.nextFloat();
sum+=score[i];
}
System.out.println("人數: "+num);
System.out.println("總分: "+sum);
System.out.println("平均: "+sum/num);
}
}
複製代碼
作者:
鄭楀諺
時間:
2019-4-20 15:06
import java.util.Scanner;
public class JPA05 {
public static Scanner keyboard = new Scanner(System.in);
public static void main(String args[]) {
int s;
float sum=0;
System.out.print("請輸入學生人數:");
s=keyboard.nextInt();
float score[] = new float[s];
for(int i=0;i<score.length;i++)
{
System.out.print("第"+(i+1)+"個學生的成績:");
score[i]=keyboard.nextFloat();
sum+=score[i];
}
System.out.println("人數:"+s);
System.out.println("總分:"+sum);
System.out.println("平均:"+sum/s);
}
}
複製代碼
作者:
黃安立
時間:
2019-4-20 15:09
import java.util.Scanner;
public class JPD05 {
public static Scanner keyboard = new Scanner(System.in);
public static void main(String args[]) {
float sum=0f;
System.out.print("請輸入學生人數:");
int num=keyboard.nextInt();
float score[]=new float[num];
for(int i=0; i<score.length; i++)
{
System.out.print("第"+(i+1)+"個學生的成績: ");
score[i]=keyboard.nextFloat();
sum+=score[i];
}
System.out.println("人數: "+num);
System.out.println("總分: "+sum);
System.out.println("平均: "+sum/num);
}
}
複製代碼
作者:
吳秉翰
時間:
2019-4-27 13:29
import java.util.Scanner;
public class JPA05 {
public static Scanner keyboard = new Scanner(System.in);
public static void main(String args[]) {
float sum = 0;
System.out.print("請輸入學生人數:");
int num = keyboard.nextInt();
float score[] = new float[num];
for (int i = 0; i < num; i++) {
System.out.print("第" + (i + 1) + "個學生的成績:");
score[i] = keyboard.nextFloat();
sum = sum + score[i];
}
System.out.println("人數:" + num);
System.out.println("總分:" + sum);
System.out.println("平均:" + sum / num);
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2