Guest User

Untitled

a guest
Apr 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. package Default;
  2.  
  3. import java.io.File;
  4. import java.io.FileNotFoundException;
  5. import java.io.PrintWriter;
  6. import java.util.Scanner;
  7.  
  8. public class DDP11102A {
  9.     public static void main (String[] args){
  10.         int jumlahSKS;
  11.         double jumlahNilai;
  12.         double nilaiIPK;
  13.         File reader = new File ("NilaiMhs.txt");
  14.         try {
  15.             Scanner input = new Scanner (reader);
  16.             PrintWriter output = new PrintWriter ("Peringatan.txt");
  17.             String nama = input.next();
  18.             String jmlhSKS = input.next();
  19.             String jmlhNilai = input.next();
  20.             jumlahSKS = (int) Double.parseDouble (jmlhSKS);
  21.             jumlahNilai = (int) Double.parseDouble (jmlhNilai);
  22.             nilaiIPK = jumlahNilai / jumlahSKS;
  23.             if ((nilaiIPK < 1.5 && jumlahSKS < 30) || (nilaiIPK < 1.75 && jumlahSKS < 60) || (nilaiIPK < 2.0 && jumlahSKS > 60)){
  24.                 System.out.println (nama + " " + jumlahSKS + " " +nilaiIPK);
  25.             }
  26.         }
  27.         catch (FileNotFoundException ex) {
  28.             System.out.println ("File not found");
  29.         }
  30.         catch (NumberFormatException ex) {
  31.             System.out.println ("Membaca yang bukan bilangan");
  32.         }
  33.     }
  34. }
Add Comment
Please, Sign In to add comment