MSadam

[ JAVA ] - Program Akhir Nilai Siswa

May 19th, 2021 (edited)
900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.86 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class App {
  4.     public static void main(String[] args) throws Exception {
  5.         Scanner input = new Scanner(System.in);
  6.         int jmlSiswa;
  7.        
  8.         // Clear Screen Console
  9.         System.out.print("\033[H\033[2J");
  10.         System.out.flush();
  11.  
  12.         // Input Jumlah Mahasiswa Yang Akan Menjadi Perulangan
  13.         System.out.println("========[ PROGRAM INPUT DATA NILAI MAHASISWA ]========\n");
  14.         System.out.print("Masukan Jumlah Mahasiswa: ");
  15.         jmlSiswa = input.nextInt();
  16.         input.nextLine();
  17.        
  18.         // Variabel
  19.         int n1[] = new int[jmlSiswa],
  20.         n2[] = new int[jmlSiswa],
  21.         n3[] = new int[jmlSiswa];
  22.        
  23.         double  m1[] = new double[jmlSiswa],
  24.         m2[] = new double[jmlSiswa],
  25.         m3[] = new double[jmlSiswa],
  26.         m4[] = new double[jmlSiswa];
  27.        
  28.         String[] nama = new String[jmlSiswa],
  29.         isNIM = new String[jmlSiswa],
  30.         isHuruf = new String[jmlSiswa];
  31.        
  32.         // Perulangan Pertama Untuk Input Data Dan Perhitungan
  33.         for(int i = 0; i < jmlSiswa; i++){
  34.             System.out.print("\033[H\033[2J");  
  35.             System.out.flush();
  36.            
  37.             System.out.println("========[ INPUT DATA MAHASISWA ]========\n");
  38.             System.out.print("Masukan NIM: ");
  39.             isNIM[i] = input.nextLine();
  40.  
  41.             System.out.print("Masukan Nama: ");
  42.             nama[i] = input.nextLine();
  43.            
  44.             System.out.print("Nilai Tugas: ");
  45.             n1[i] = input.nextInt();
  46.            
  47.             System.out.print("Nilai UTS: ");
  48.             n2[i] = input.nextInt();
  49.  
  50.             System.out.print("Nilai UAS: ");
  51.             n3[i] = input.nextInt();
  52.             input.nextLine();
  53.  
  54.             // Rumus Nilai
  55.             m1[i] = n1[i]*0.15;
  56.             m2[i] = n2[i]*0.35;
  57.             m3[i] = n3[i]*0.50;
  58.             m4[i] = m1[i] + m2[i] + m3[i];
  59.            
  60.             // Kondisi Letter Ranking
  61.             if((int)m4[i] >= 80){
  62.                 isHuruf[i] = "A";
  63.             }else if((int)m4[i] >= 70){
  64.                 isHuruf[i] = "B";
  65.             }else if((int)m4[i] >= 60){
  66.                 isHuruf[i] = "C";
  67.             }else if((int)m4[i] >= 50){
  68.                 isHuruf[i] = "D";
  69.             }else{
  70.                 isHuruf[i] = "E";
  71.             }
  72.         }
  73.  
  74.         // Clear Screen Console
  75.         System.out.print("\033[H\033[2J");  
  76.         System.out.flush();
  77.  
  78.         // Output Judul
  79.         System.out.println("No.\tNIM\tNAMA\tN.TUGAS\tN.UTS\tN.UAS\tN.AKHIR\tN.HURUF");
  80.        
  81.         // Perulangan Untuk Output
  82.         for(int i = 0; i<jmlSiswa; i++){
  83.             System.out.println(i+1 + "\t" + isNIM[i] + "\t" + nama[i] + "\t" + (int)n1[i] + "\t" + (int)n2[i] + "\t" + (int)m3[i] + "\t" + (int)m4[i] + "\t" + isHuruf[i]);
  84.         }
  85.     }
  86. }
Add Comment
Please, Sign In to add comment