Skip to content

Instantly share code, notes, and snippets.

@AuroraNorthernQuarter
Created October 22, 2018 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AuroraNorthernQuarter/fe9b3090017824be587f69af7538bcd5 to your computer and use it in GitHub Desktop.
Save AuroraNorthernQuarter/fe9b3090017824be587f69af7538bcd5 to your computer and use it in GitHub Desktop.
package testprogramm;
import java.util.Scanner;
public class Sample {
static void Disp(String[] name, double[] height){
int n = name.length;
double sum = 0;
for (int i = 0; i < n; i++) {
System.out.println(name[i] + ":" + height[i] + "cm");
sum = sum + height[i];
}
System.out.println("平均:" + sum/n+ "cm");
}
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
while (true) {
System.out.print("得点を入力してください: ");
// キーボードから整数の入力を受け取る
int score = scan.nextInt();
if (score > 90) {
System.out.println("おめでとう! 合格です");
String name[] = new String[3];
double height[] = new double[3];
name[0] = "鈴木";
name[1] = "杉山";
name[2] = "田中";
height[0] = 168.7;
height[1] = 173.4;
height[2] = 155.8;
Disp(name,height);
break;
} else if (score >= 60) {
System.out.println("もう少し頑張りましょう。");
String name[] = new String[3];
double height[] = new double[3];
name[0] = "橋本";
name[1] = "高杉";
name[2] = "佐藤";
height[0] = 166.3;
height[1] = 159.1;
height[2] = 177.4;
Disp(name,height);
break;
} else if (score < 0) {
break;
}
}
scan.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment