Skip to content

Instantly share code, notes, and snippets.

@AuroraNorthernQuarter
Created October 23, 2018 11:39
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/2009ed72ff12b482820a5a629560f0f9 to your computer and use it in GitHub Desktop.
Save AuroraNorthernQuarter/2009ed72ff12b482820a5a629560f0f9 to your computer and use it in GitHub Desktop.
package testprogramm;
import java.util.Scanner;
public class Sample {
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];
double sum = 0;
name[0] = "鈴木";
name[1] = "杉山";
name[2] = "田中";
height[0] = 168.7;
height[1] = 173.4;
height[2] = 155.8;
for (int j = 0; j <= 2; j++) {
int i = 0;
System.out.println(name[i] + ":" + ( ( i != j ) ? (height[i] + "cm") : "" ));
sum = sum + height[i];
}
System.out.print("平均:" + sum/3);
break;
}
else if (score >= 60) {
System.out.println("もう少し頑張りましょう。");
String name[] = new String[3];
double height[] = new double[3];
double sum = 0;
name[0] = "橋本";
name[1] = "高杉";
name[2] = "佐藤";
height[0] = 166.3;
height[1] = 159.1;
height[2] = 177.4;
for (int j = 0; j <= 2; j++) {
int i = 0;
sum = sum + height[i];
System.out.println(name[i] + ":" + ( ( i != j ) ? (height[i] + "cm") : "" ));
}
System.out.print("平均:" + sum/3);
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