Advertisement
TheSTRIG

Lab 10

Dec 6th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.42 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.io.FileNotFoundException;
  3. import java.io.FileReader;
  4. import java.io.FileWriter;
  5. import java.io.BufferedWriter;
  6. import java.io.PrintWriter;
  7. import java.util.Scanner;
  8.  
  9. public class HitungIP{
  10.     public static void main(String[] args) throws FileNotFoundException {
  11.         //tambahkan variabel atau object-object bila diperlukan
  12.         try{
  13.         // Minta nama file input.
  14.         Scanner scan = new Scanner(System.in);
  15.         System.out.print("Input file: ");
  16.         String inputFileName = scan.next();
  17.        
  18.         // Buka file input.
  19.         File inputFile = new File(inputFileName);
  20.        
  21.         // Baca baris pertama yang berisi tahun ajaran.
  22.         Scanner sc = new Scanner(inputFile);
  23.         int lineNumber = 1;
  24.        
  25.         // Lakukan validasi tahun ajaran
  26.         // throw exception anda sendiri kalau terjadi error
  27.         // while loop untuk memproses data dari file
  28.             while (. . . ) {
  29.             // baca baris dari file input
  30.             // manipulasi input jika diperlukan
  31.             // gunakan method hitungIP() untuk menghitung IP
  32.             // simpan data sesuai kategori
  33.             }
  34.         // tambahkan statement yang diperlukan
  35.         }
  36.         catch (. . . ) {
  37.         }
  38.         catch (. . . ) {
  39.         }
  40.         catch (. . . ) {
  41.         }
  42.     }
  43.     /**
  44.     * TO DO lengkapi method berikut!
  45.     * Method untuk menghitung nilai IP
  46.     */
  47.     public static double hitungIP(. . .){
  48.         try {
  49.         }
  50.         catch (. . .) {
  51.         }
  52.     }
  53. /**
  54. * Tambahkan method anda sendiri jika diperlukan
  55. */
  56. }
  57. /**
  58. * Buat kelas exception anda sendiri jika diperlukan
  59. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement