티스토리 뷰
public void ex8() { String[] names; names = new String[] {"홍길동", "일지매", "임꺽정", "성춘향","이몽룡"}; int[] kor; kor = new int[] {99, 90, 70, 60, 50}; int[] eng; eng = new int[] {67, 90, 70, 60, 50}; int[] total = new int[5]; double[] avg = new double[5]; //연산for문 한 번, 출력for문 한 번 이런 식으로 작성해주세요. int i=0; for (i=0; i<5; i++) { total[i] = kor[i] + eng[i]; avg[i] = total[i]/3.0; } System.out.println("----------------------------"); System.out.println(" 성적표"); System.out.println("----------------------------"); System.out.println(" 성명 국어 영어 총점 평균 "); System.out.println("----------------------------"); for (i=0; i<5; i++) { System.out.printf("%5s %4d %4d %4d %6.2f\n", names[i], kor[i], eng[i], total[i], avg[i]); } System.out.println("----------------------------"); }
- 배열에 문자열과 정수를 저장해 출력하기 - 성적표 출력하기
'배움과 복습' 카테고리의 다른 글
2017-08-30 수요일 : 다차원 배열 (0) | 2017.08.30 |
---|---|
API 문서 보는 방법 (0) | 2017.08.29 |
2017-08-29 화요일 배움: 배열(Array) (0) | 2017.08.29 |
2017-08-28 월요일 배움 : for문과 while문 : 반복문 (0) | 2017.08.28 |
2017-08-25 금요일 배움 5일 (0) | 2017.08.25 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 테이블 데이터 복사
- 타입변환과 다형성
- 멤버 클래스
- hierarchical query
- 데이터 딕셔너리
- IS RECORD
- DI(의존성 주입)
- SELECT절 명령어
- implements
- z-dindex
- SQL Operator
- Maven Project
- IN(var1 var2 var3)
- Generic Type
- tables in htmll
- MONTH_BETWEEN
- Interface
- FileChannel
- 상속
- GROUP BY절
- NVL2()
- DECODE()
- 계층형 쿼리
- NVL()
- CLASS
- !(not)
- 복수행 함수
- 중첩 클래스
- casring
- 로컬 클래스
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함