영상
문제
package 배열7_문제;
/*
[문제]
아래 scoreList 데이터는 학생 6명의 점수이다.
이 데이터를 그래프로 표현하려고 한다.
표시는 10의 자리 숫자로 표현해서
개수만큼 *로 출력하시오.
[정답]
31 : ***
76 : *******
54 : *****
2 :
100 : **********
23 : **
*/
public class 배열7_문제01_그래프_문제 {
public static void main(String[] args) {
int[] scoreList = {31, 76, 54, 2, 100, 23};
}
}
Java
복사
해설
package 배열7_문제;
/*
[문제]
아래 scoreList 데이터는 학생 6명의 점수이다.
이 데이터를 그래프로 표현하려고 한다.
표시는 10의 자리 숫자로 표현해서
개수만큼 *로 출력하시오.
[정답]
31 : ***
76 : *******
54 : *****
2 :
100 : **********
23 : **
*/
public class 배열7_문제01_그래프_정답 {
public static void main(String[] args) {
int[] scoreList = {31, 76, 54, 2, 100, 23};
for(int i=0; i<scoreList.length; i++) {
System.out.print(scoreList[i] + "\t:");
int count = scoreList[i] / 10;
// System.out.println(count);
for(int j=0; j<count; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
Java
복사