공책

사람 성적 등록 본문

웹 개발/Java

사람 성적 등록

QTHoney 2013. 8. 29. 12:45

package ex1;


import java.util.Scanner;


public class Ex2_work {

public static void main(String[] args) {

//학생들의 수학과 영어성적을 등록하는 프로그램이 있다

//프로그램을 실행하면 몇 명의 정보를 저장 할 것인지를 

// 입력 받은 후, 입력받은 수 만큼 학생들의 이름과 수학서적, 영어성적을 입력받는 프로그램 작성

// 결과 : 

// 등록 할 인원 수 : 2

// 이름 : 홍길동

// 수학 : 90

// 영어 : 50

// -------------------------

// 이름 : 김갤동

// 수학 : 90

// 영어 : 50

// -----------------------------

// 2명 등록 완료

// 이름 : 홍길동

// 수학 : 90

// 영어 : 50

// -------------------------

// 이름 : 김갤동

// 수학 : 90

// 영어 : 50

Scanner sc = new Scanner(System.in);

Scanner sc1 = new Scanner(System.in);

int cnt = 0;

System.out.print("등록 할 인원 수 : ");

cnt = sc.nextInt();


String[][] student = new String[cnt][3];

for ( int i = 0; i < cnt; i ++){

System.out.println("-----------------------------------");

System.out.print("이름 : ");

student[i][0] = sc1.nextLine();

System.out.print("수학 : ");

student[i][1] = sc1.nextLine();

System.out.print("영어 : ");

student[i][2] = sc1.nextLine();

}

for (int i = 0; i< student.length; i++){

System.out.println("---------------------------------");

System.out.println("이름 : " + student[i][0] + "\n수학 : "+ student[i][1] + "\n영어 : "+ student[i][2]);

}

}

}



'웹 개발 > Java' 카테고리의 다른 글

입력받은 문자열중 특정 문자열이 몇개 인지 찾는 로직  (0) 2013.08.29
String의 특징  (0) 2013.08.29
2차원 배열의 모든합 평균 구하기  (0) 2013.08.29
베이스볼 게임 만들기  (0) 2013.08.29
로또 만들기  (0) 2013.08.28
Comments