개발/java
자바 성적관리프로그램(부함수부분)
HEURISTIC_
2013. 10. 1. 17:55
package oop.capsule; import java.util.Scanner; public class RecordView { static int inputMenu() //메뉴출력함수 { Scanner scan= new Scanner(System.in); int menu; System.out.println("┌─────────────────┐"); System.out.println("│ 메인 메뉴 │"); System.out.println("└─────────────────┘"); System.out.print("\t\t1.성적 입력\n"); System.out.print("\t\t2.성적 출력\n"); System.out.print("\t\t3.종료\n"); menu = scan.nextInt(); return menu; } static void inputRecord(Record record) //성적입력함수 { Scanner scan= new Scanner(System.in); int kor, eng, math; //임시변수선언 System.out.println("┌─────────────────┐"); System.out.println("│ 성적 입력 │"); System.out.println("└─────────────────┘"); do{ System.out.println("\t\t국어 :"); kor = scan.nextInt(); if(kor<0 || kor>100) System.out.println("범위벗어남"); } while(kor<0 || kor>100); do{ System.out.print("\t\t영어 :"); eng = scan.nextInt(); if(eng<0 || eng>100) System.out.println("범위벗어남"); } while(eng<0 || eng>100); do{ System.out.print("\t\t수학 :"); math = scan.nextInt(); if(math<0 || math>100) System.out.println("범위벗어남"); } while(math<0 || math>100); Record.setKor(record,kor); Record.setEng(record,eng); Record.setMath(record,math); } static void printRecord(Record record)//성적출력함수 { int total = Record.total(record); float avg = total / 3.0f; System.out.printf("┌─────────────────┐\n"); System.out.printf("│ @본인 이름 성적표@ │\n"); System.out.printf("├──┬──┬──┬──┬──┬──┤\n"); System.out.printf("│번호│국어│영어│수학│총점│평균│\n"); for(int i=0 ; i<3 ; i++) { System.out.printf("├──┼──┼──┼──┼──┼──┤\n"); System.out.printf("│%-5d│%-5d│%-5d│%-5d│%-5d│%4.2f│\n", i+1,Record.getKor(record),Record.getEng(record),Record.getMath(record),total,avg); } System.out.printf("└──┴──┴──┴──┴──┴──┘\n"); } }