JAVA/1. 기본문법01
성적처리 프로그램 예제1
날아올라↗↗
2015. 12. 1. 01:27
728x90
반응형
- package test.com;
- public class Test04Score {
- public static void main(String[] args) {
- //성적처리 프로그램
- String nKor = "국어";
- String nEng = "영어";
- String nMath = "수학";
- int korScore = 100;
- int engScore = 49;
- int mathScore = 98;
- int totalSum = korScore+engScore+mathScore;
- double totalAvg = totalSum/3;
- String inputComment = " 점수를 입력학세요 : ";
- String line = "========================";
- //변수의 상수 처리를 위한 final
- final String TITLE = "[성적처리 프로그램]";
- System.out.println(TITLE);
- System.out.println(line);
- System.out.println(nKor + inputComment + korScore);
- System.out.println(nEng + inputComment + engScore);
- System.out.println(nMath + inputComment + mathScore);
- System.out.println(line);
- System.out.println(" 총점 : " + totalSum);
- System.out.println(" 평균 : " + totalAvg);
- String grade = "";
- grade =
- totalAvg >=90 ? "A Class" :
- totalAvg >=80 ? "B Class" :
- totalAvg >=70 ? "C Class" :
- "D Class";
- System.out.println(" 등급 : " + grade);
- System.out.println(line);
- System.out.println("프로그램을 종료합니다..");
- System.out.println("공자왈 "지덕체" ");
- System.out.println("1000\10");
- // http://www.naver.com
- // c:javastudy emp --> c:\javastudy\temp
- }
- }
============================================
성적처리 프로그램 예제01
[라인설명]
7~9 : 각 과목명 String변수 초기화
11~13 : 각 과목점수 int변수 초기화
15 : 총점 int 초기화
16 : 평균 double타입 초기화
22 : 프로그램 제목은 변경할 일이 없으므로 final설정하여 재정의 불가설정
37 : 등급정의
38~42 : 3항연산자를 사용하여 각 점수대별 등급을 정리
728x90
반응형