Monday, April 18, 2011

program mencari alamat relatif matkul sistem berkas

import java.io.*;

class ar {
public static void main(String[] args) throws IOException {

String NPM, kode;
int hb, hb2, hb3, hb4, hb5, ar, ar2, ar3, ar4, ar5, n, k, nkey, nkey2, nkey3, nkey4, nkey5;

int record = 5832;
int max = 8331;
int fp = 11;

InputStreamReader j = new InputStreamReader(System.in);
BufferedReader m = new BufferedReader(j);

System.out.print("Soal\t:\nBuat 5 key dengan \nKey awal = NPM + Kode mata kuliah\nKey 2\t = Key awal + 3"
+ "\nKey 3\t = Key 2 + 11\nKey 4\t = Key 3 + 17\nKey 5\t = Key 4 + 23"+
"\n\nDengan diketahui :\n- Jumlah record\t= 5832\n- Faktor Muat\t= 0,7\n- Faktor Prima\t= 11");

System.out.print("\n\nMasukkan NPM : ");
NPM = m.readLine();
n = Integer.valueOf(NPM).intValue();

System.out.print("\nMasukkan kode MK : ");
kode = m.readLine();
k = Integer.valueOf(kode).intValue();

nkey = n + k;
hb = nkey / (max + fp);
ar = (nkey % 8342) + 1;

nkey2 = nkey + 3;
hb2 = nkey2 / (max + fp);
ar2 = (nkey2 % 8342) + 1;

nkey3 = nkey2 + 11;
hb3 = nkey3 / (max + fp);
ar3 = (nkey3 % 8342) + 1;

nkey4 = nkey3 + 17;
hb4 = nkey4 / (max + fp);
ar4 = (nkey4 % 8342) + 1;

nkey5 = nkey4 + 23;
hb5 = nkey5 / (max + fp);
ar5 = (nkey5 % 8342) + 1;

System.out.print("\nKey awal\n");
System.out.print("Hasil Bagi\t= " + hb);
System.out.print("\nAlamat Relatif = " + ar);

System.out.print("\n\nKey kedua\n");
System.out.print("Hasil Bagi\t= " + hb2);
System.out.print("\nAlamat Relatif = " + ar2);

System.out.print("\n\nKey ketiga\n");
System.out.print("Hasil Bagi\t= " + hb3);
System.out.print("\nAlamat Relatif = " + ar3);

System.out.print("\n\nKey keempat\n");
System.out.print("Hasil Bagi\t= " + hb4);
System.out.print("\nAlamat Relatif = " + ar4);

System.out.print("\n\nKey kelima\n");
System.out.print("Hasil Bagi\t= " + hb5);
System.out.print("\nAlamat Relatif = " + ar5);
}
}

Share

No comments:

Post a Comment