/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mergesort;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;
/**
*
* @author aisyah
*/
public class Main {
public static void main(String[] args) {
MergeSort sorting = new MergeSort();
int x = 0;
Scanner pilihan = new Scanner(System.in);
Scanner direktori = new Scanner(System.in);
Scanner tampil = new Scanner(System.in);
Scanner tampil2 = new Scanner(System.in);
String dir = null;
do {
System.out.println("==========================");
System.out.println("M E N U - P I L I H A N");
System.out.println("1. masukkan direktori file");
System.out.println("2. Tampil data (konsol)");
System.out.println("3. Sorting nama depan");
System.out.println("4. Sorting nama belakang");
System.out.println("5. Keluar");
System.out.println("==========================");
System.out.print("masukkan pilihan : ");
x = pilihan.nextInt();
switch (x) {
case 1:
System.out.print("masukkan direktori file, jika ada tanda \\ tulis 2 kali : ");
//contoh : G:\\kuliah\\tugas\\ALPRO1\\prak7\\MergeSort-5210105003\\Data Nama.txt
String k = direktori.nextLine();
dir = k;
break;
case 2:
try {
sorting.tampil(dir);
} catch (FileNotFoundException e) {
System.out.println("file tidak ditemukan");
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
break;
case 3:
try {
sorting.array(dir);
sorting.pisahKata(sorting.temp);
sorting.mergesort(sorting.nama, 0, sorting.nama.length-1);
} catch (FileNotFoundException e) {
System.out.println("file tidak ditemukan");
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("apakah mau ditampilkan di konsol? (y=1/n=2)");
int ya = tampil.nextInt();
//String pil = ya.toString();
if (ya == 1) {
for (int i = 0; i < 220; i++) {
for (int j = 0; j < 3; j++) {
if (sorting.nama[i][j] != "") {
System.out.print(sorting.nama[i][j] + " ");
}
}
System.out.println("");
}
sorting.buatFile("sorting_nama_depan");
}else if(ya == 2) {
sorting.buatFile("sorting_nama_depan");
}else{
System.out.println("anda tidak memasukkan pilihan yang benar!");
}
break;
case 4:
try {
sorting.array(dir);
sorting.pisahKata(sorting.temp);
sorting.mBalik(sorting.nama);
sorting.mergesort(sorting.nama, 0, sorting.nama.length-1);
sorting.mBalik(sorting.nama);
} catch (FileNotFoundException e) {
System.out.println("file tidak ditemukan");
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("apakah mau ditampilkan di konsol? (y=1/n=2)");
int yak = tampil2.nextInt();
if (yak == 1) {
for (int i = 0; i < 220; i++) {
for (int j = 0; j < 3; j++) {
if (sorting.nama[i][j] != "") {
System.out.print(sorting.nama[i][j] + " ");
}
}
System.out.println("");
}
sorting.buatFile("sorting_nama_blk");
}else if(yak == 2) {
sorting.buatFile("sorting_nama_blk");
}else{
System.out.println("anda tidak memasukkan pilihan yang benar!");
}
break;
case 5:
System.exit(1);
}
} while (x < 6);
}
}
em flowchart nya mana sob?
BalasHapushehe gak ada pak... emang gak dibuat
BalasHapus