728x90
반응형
SMALL
package 오후;
public class StudentScore {
private String name;
private int scoreJava;
private int scoreWeb;
private int scoreAndroid;
public StudentScore(String name, int scoreJava, int scoreWeb, int scoreAndroid) {
super();
this.name = name;
this.scoreJava = scoreJava;
this.scoreWeb = scoreWeb;
this.scoreAndroid = scoreAndroid;
}
public String getName() {
return name;
}
public int getScoreJava() {
return scoreJava;
}
public int getScoreWeb() {
return scoreWeb;
}
public int getScoreAndroid() {
return scoreAndroid;
}
}
package 오후;
import java.util.Scanner;
public class StudentScoreMain {
public static void main(String[] args) {
//StudentScore객체 배열에 대한 레퍼런스 변수 선언
StudentScore[] ssArray;
//3명의 학생 데이터를 입력할 수 있도록 StudentScore객체 배열 생성
ssArray = new StudentScore[3];
// StudentScore ss1;
// StudentScore ss2;
// StudentScore ss3;
Scanner sc = new Scanner(System.in);
for(int i=0;i<ssArray.length;i++) {
System.out.print(i+1 + "번째 학생의 이름을 입력하세요. >>");
String name = sc.next();
System.out.print(i+1 + "번째 학생의 Java점수를 입력하세요. >>");
int scoreJava = sc.nextInt();
System.out.print(i+1 + "번째 학생의 Web점수를 입력하세요. >>");
int scoreWeb = sc.nextInt();
System.out.print(i+1 +"번째 학생의 Android점수를 입력하세요. >>");
int scoreAndroid = sc.nextInt();
System.out.println();
ssArray[i]=new StudentScore(name, scoreJava, scoreWeb, scoreAndroid);
}
for(int i=0;i<ssArray.length;i++) {
System.out.println(ssArray[i].getName()+"님의 총점은 "+
(ssArray[i].getScoreJava()+ssArray[i].getScoreWeb()+ssArray[i].getScoreAndroid())
+ "점이고, 평균은 "
+ (ssArray[i].getScoreJava()+ssArray[i].getScoreWeb()+ssArray[i].getScoreAndroid())/3
+ "점 입니다."
);
}
}
}
728x90
반응형
LIST
'스마트인재개발원 > 자바' 카테고리의 다른 글
[자바/DB] JDBC - 정보 입력 받아 출력 및 수정 (0) | 2022.09.27 |
---|---|
[자바/DB] JDBC (0) | 2022.09.27 |
[자바]약수 구하기 (0) | 2022.09.19 |
[자바] 치환/ 버블정렬 (0) | 2022.09.16 |
[자바]이차원배열 초기화 및 출력 다양한 형태 (0) | 2022.09.16 |