총 10분 중 11분
2001
시즌 2개, 그리고 영화
시즌 2:
5화
“아일랜드”
출연: 이나영, 김민준, 김민정, 현빈
장르: 애초에 역경을 딛고 이룩하는 숭고한 사랑이란 없다. 그 역경 자체가 사랑이다.
프로그램 특징: 그 곳에서 살아남는 사랑이 어떤 모습으로 걸어오는지 기다려 보고 싶다.
장르: 애초에 역경을 딛고 이룩하는 숭고한 사랑이란 없다. 그 역경 자체가 사랑이다.
프로그램 특징: 그 곳에서 살아남는 사랑이 어떤 모습으로 걸어오는지 기다려 보고 싶다.
회차
Computer Science/Object Oriented Programming
[JAVA] 이것이 자바다(3판) 5장 9번 답안
728x90
반응형
9. 키보드로 학생 수와 각 학생들의 점수를 입력받고 최고 점수 및 평균 점수를 출력하는 코드를 작성해보세요.
package ch05.referenceType;
import java.util.Scanner;
public class Chap5 {
public static void main(String[] args) {
boolean run = true;
Scanner sc = new Scanner(System.in);
int studentNum = 0;
Integer[] scoreList = null;
int max = 0;
int total = 0;
while (run) {
System.out.println("""
-----------------------------------------------------------------------------------------
1. The number of Student || 2. Insert Score || 3. Score List || 4. Analysis || 5. Close
-----------------------------------------------------------------------------------------
""");
System.out.println("Enter the number in a given order: ");
int n = sc.nextInt();
switch (n) {
case 1: {
System.out.println("Enter the student number: ");
studentNum = sc.nextInt();
scoreList = new Integer[studentNum];
continue;
}
case 2: {
for (int i = 0; i < studentNum; i++) {
System.out.println("Enter student " + (i + 1) + " score: ");
scoreList[i] = sc.nextInt();
}
continue;
}
case 3: {
if (scoreList == null) {
System.out.println("return to prev progress");
continue;
}
for (int i = 0; i < studentNum; i++) {
System.out.println("student " + (i + 1) + " score: " + scoreList[i]);
}
continue;
}
case 4: {
if (scoreList == null) {
System.out.println("return to prev progress");
continue;
}
for (int i = 0; i < studentNum; i++) {
if (scoreList[i] > max) {
max = scoreList[i];
}
total += scoreList[i];
}
System.out.println("Average score: " + total / studentNum);
System.out.println("Max score: " + max);
continue;
}
case 5: {
System.out.println("Close the program");
run = false;
}
}
}
}
}
728x90
'Computer Science > Object Oriented Programming' 카테고리의 다른 글
[JAVA] 이것이 자바다(3판) 6장 20번 답안 (0) | 2025.04.17 |
---|---|
[JAVA] 참조형 : 배열 초기화, 복사 (1) | 2025.04.16 |
[cpp] 복사 생성자 (4) | 2024.11.13 |
[Template] Class template (0) | 2024.10.18 |
[Class] Method (3) | 2024.10.16 |
2025:04:15
Computer Science/Object Oriented Programming
[JAVA] 이것이 자바다(3판) 5장 9번 답안