본문 바로가기
Class/220728

Class(2-1)

by pms93 2022. 7. 28.
package constructor;

import java.util.Scanner;

public class StudentMain {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String name;
		int kor, mat, eng;
		
		System.out.print("이름 : ");
		name = sc.nextLine();
		System.out.print("국어 : ");
		kor = sc.nextInt();
		System.out.print("영어 : ");
		eng = sc.nextInt();
		System.out.print("수학 : ");
		mat = sc.nextInt();
		
		// 불변객체
		Student student = new Student(name, kor, eng, mat);
		
		System.out.printf("이름 : %s\n국어 : %d\n영어 : %d\n수학 : %d\n------------------------------\n"
				+ "합계 : %d\n평균 : %.2f", student.getName(), student.getKor(), student.getEng()
				, student.getMat(), student.getTotal(), student.getAvg());
		
	}
}

'Class > 220728' 카테고리의 다른 글

Class_Overload(1-2)  (0) 2022.07.28
Class_Overload(1-1)  (0) 2022.07.28
Class(2-2)  (0) 2022.07.28
Class(1-2)  (0) 2022.07.28
Class(1-1)  (0) 2022.07.28