일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 다운캐스팅
- Validations
- IBatis procedure
- 추상클래스
- 다형성
- 형변환
- 전체
- 전체텍스트
- full text indexing
- Full text
- 로또
- Login with OAuth Authentication
- 전자정부
- 페이징
- Random
- 야구게임
- angular2
- 이클립스
- 가변인자
- 상속
- jquery
- 자바 야구게임
- 자바
- while
- 업캐스팅
- 단축키
- 스프링
- 25가지 효율적인 sql작성법
- 상속예제
Archives
- Today
- Total
nalaolla
성적처리 프로그램 예제2 (Scanner사용) 본문
728x90
- package test.com;
- import java.util.Scanner;
- public class Test04Score2 {
- public static void main(String[] args) {
- Test04ScoreSub scoresub = new Test04ScoreSub();
- scoresub.ScorePrint();
- }
- }
- class Test04ScoreSub{
- public void ScorePrint(){
- System.out.println("[성적관리 프로그램]");
- System.out.println("=========================");
- Scanner scanner = new Scanner(System.in);
- System.out.println("국어점수입력");
- int korScore = scanner.nextInt();
- System.out.println("영어점수입력");
- int engScore = scanner.nextInt();
- System.out.println("수학점수입력");
- int mathScore = scanner.nextInt();
- int scoreSum = 0;
- double scoreAvg = 0;
- scoreSum = korScore + engScore + mathScore;
- scoreAvg = scoreSum / 3;
- System.out.println("=========================");
- System.out.println("총점 : " + scoreSum);
- System.out.println("평균 : " + scoreAvg);
- System.out.println("=========================");
- System.out.println("[프로그램 종료]");
- scanner.close();
- }
- }
===================================================
성적처리01 예제와 비슷
Test04Score2 클래스와 실제 기능구현하는 Test04ScoreSub로 구분하여 진행
Test04Score2에서 Test04ScoreSub의 인스턴스 생성후 해당 메소드인 ScorePrint()호출
java.uti.Scanner클래스 인스턴스 객체 생성후 Console창에서 해당 내용을 입력받아 정보 출력하는 방식
728x90
'JAVA > 1. 기본문법01' 카테고리의 다른 글
기본자료형 및 변수선언 정리1 (0) | 2015.12.01 |
---|---|
게시판예제 01 (0) | 2015.12.01 |
성적처리 프로그램 예제1 (0) | 2015.12.01 |
타입별 System.out.println(...) (0) | 2015.12.01 |
이클립스 기본 단축키 정리 (0) | 2015.12.01 |