관리 메뉴

nalaolla

배열예제 14 본문

JAVA/4. Array

배열예제 14

날아올라↗↗ 2016. 6. 22. 17:05
728x90
  1. package test.com;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class WhyNeedArray {
  6.  
  7.     public static void main(String[] args) {
  8.         // TODO Auto-generated method stub
  9.        
  10.         int fstHighScore = 0;
  11.         int sndHighScore = 0;
  12.        
  13.         Scanner sc = new Scanner(System.in);
  14.         System.out.println("점수입력");
  15.         int score1 = sc.nextInt();
  16.        
  17.         if (score1 >= fstHighScore) {
  18.             sndHighScore = fstHighScore;
  19.             fstHighScore = score1;
  20.         } else if (score1 < fstHighScore && score1 > sndHighScore) {
  21.             sndHighScore = score1;
  22.         }
  23.        
  24.         System.out.println("점수입력");
  25.         int score2 = sc.nextInt();
  26.        
  27.         if (score2 >= fstHighScore) {
  28.             sndHighScore = fstHighScore;
  29.             fstHighScore = score2;
  30.         } else if (score2 < fstHighScore && score2 > sndHighScore) {
  31.             sndHighScore = score2;
  32.         }
  33.        
  34.        
  35.        
  36.         System.out.printf("학점은 %d점 이상입니다.", sndHighScore);
  37.  
  38.     }
  39.  
  40. }


728x90

'JAVA > 4. Array' 카테고리의 다른 글

배열예제 13 (객체 배열)  (0) 2016.06.22
배열예제 12 (다중배열 2)  (0) 2016.06.22
배열예제 11 (다중배열)  (0) 2016.06.22
배열예제 10 (점수관리 배열2)  (0) 2016.06.22
배열예제 9 (점수관리 배열)  (0) 2016.06.22