Created
October 21, 2018 04:17
-
-
Save AuroraNorthernQuarter/196c7a8fb85fe967f5a5ecacf6a5d50e to your computer and use it in GitHub Desktop.
サンプルコードその2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 i = 0; i <= 2; i++) { | |
System.out.println(name[i] + ":" + 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 i = 0; i <= 2; i++) { | |
System.out.println(name[i] + ":" + height[i] + "cm"); | |
sum = sum + height[i]; | |
} | |
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