1.요구 사항
-3명의 성적을 받는다
-각 3과목의 성적을 받는다.
-총합과 평균 점수도 출력한다.
-배열을 사용한다.
2.결과 화면 및 샘플
3.소스 코드
int[] sungjuk = new int[9]; string[] arrGwaMok = { "국어", "영어", "수학" }; string[] arrStudentName = { "홍길동", "임꺽정", "나철수" }; float total = 0; for (int i = 0; i < arrGwaMok.Length; i++) { for (int j = 0; j < arrGwaMok.Length; j++) { Console.WriteLine(arrStudentName[i] + "의" + arrGwaMok[j] + " 성적을 입력해 주세요."); Console.Write(arrStudentName[i] + ">"); sungjuk[(i * 3) + j] = int.Parse(Console.ReadLine()); } Console.Clear(); } Console.WriteLine("==============성적표============="); for (int i = 0; i < arrGwaMok.Length; i++) { for (int j = 0; j < arrGwaMok.Length; j++) { Console.WriteLine(" " + arrStudentName[i] + "의" + arrGwaMok[j] + " 점수" + sungjuk[(i * 3) + j]); total += sungjuk[(i * 3) + j]; } Console.WriteLine(" " + arrStudentName[i] + "의" + " 총점" + total); Console.WriteLine(" " + arrStudentName[i] + "의" + " 평균" + (total / 3.0)); total = 0; } Console.WriteLine("==============성적표============="); Console.ReadKey();
'정리 카테고리 > 실습_과제' 카테고리의 다른 글
실습_배열로 과목별 성적 받고 성적 및 합계,평균 출력 (0) | 2018.03.13 |
---|---|
실습_수량 제한 있는 가방에 아이템 줍기_배열사용 (0) | 2018.03.12 |
실습_아이템 확인+집기+버리기+순서확인 (0) | 2018.03.12 |
실습_아이디 비밀번호 직업 선택 프로그램 (0) | 2018.03.08 |
실습_로또 생성기 (2) | 2018.03.07 |