Advertisement
wewgu

Untitled

Oct 12th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. package learning;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Learning
  6. {
  7.   public static void main(String[]args)
  8.   {
  9.     Scanner scanner = new Scanner(System.in);
  10.     int[] npm = {70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
  11.                 80, 81, 82, 83, 84, 85, 86, 87, 88, 89};
  12.     String[] mahasiswa = {"Joni", "Andi", "Siti", "Eliana", "Mira", "Vina", "Tuti", "Tono", "Yanto", "Asti",
  13.                         "Ryan", "Doni", "Yandi", "Tanti", "Suryo", "Eko", "Mike", "Neil", "Rocky"};
  14.  
  15.     int x = 0;
  16.    
  17.     System.out.println("Silahkan masukkan npm sebanyak 10 kali");
  18.    
  19.     while(x<10) //This looping for user can input NPM 10 times only
  20.     {
  21.         int inputNpm = scanner.nextInt();
  22.        
  23.         for(int i=0;i<npm.length;i++)
  24.         {
  25.             if(inputNpm == npm[i])
  26.             {
  27.                 System.out.println(mahasiswa[i] + "\n");
  28.             }
  29.         }
  30.        
  31.         x++;
  32.     }
  33.    
  34.     System.out.println("--- SELESAI ---"); //If total input of NPM is 10, this statement is gonna be printed
  35.   }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement