Pada UTS PBO B pada tanggal 15 Oktober 2018, kami ditugaskan untuk membuat program Sistem Parkir Elektronik pada soal nomor 5. Berikut adalah hasil dan source code nya.
1. Class main
/**
* Write a description of class Main here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
int menu=0;
String nopol;
int price;
PrintMasuk masuk = new PrintMasuk();
System.out.println("Masukkan Nomor Polisi Kendaraan Anda");
nopol=masuk.getNopol();
price=masuk.getPrice();
while(menu!=2)
{
System.out.println("1. Cetak Bukti Masuk");
System.out.println("2. Cetak Resi Keluar");
menu=scan.nextInt();
switch(menu)
{
case 1:
masuk.printMasuk();
break;
case 2:
PrintKeluar keluar = new PrintKeluar();
keluar.nopol=nopol;
keluar.price=price;
keluar.hourmasuk=masuk.hour;
keluar.minmasuk=masuk.min;
keluar.secmasuk=masuk.sec;
keluar.printKeluar();
break;
}
}
}
}
2. Class PrintMasuk
/**
* Write a description of class PrintMasuk here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.Scanner;
import java.util.Calendar;
import java.util.Date;
public class PrintMasuk
{
Scanner scan = new Scanner(System.in);
private String nopol;
private int price;
Calendar rightNow = Calendar.getInstance();
int hour = rightNow.get(Calendar.HOUR_OF_DAY);
int min = rightNow.get(Calendar.MINUTE);
int sec = rightNow.get(Calendar.SECOND);
public String getNopol()
{
nopol = scan.nextLine();
return nopol;
}
public int getPrice()
{
price=2000;
return price;
}
public void printMasuk()
{
System.out.println("######################");
System.out.println("#####Parkiran TC#####");
System.out.println("#####Bukti Masuk#####");
System.out.println("###### "+String.format("%02d",hour)+":"+String.format("%02d",min)+":"+String.format("%02d",sec)+" ######");
System.out.println("#Nomor Polisi "+nopol+"#");
System.out.println("######################");
System.out.println();
}
}
3. Class PrintKeluar
/**
* Write a description of class PrintKeluar here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.Calendar;
import java.util.Date;
public class PrintKeluar
{
public String nopol;
public int price;
Calendar rightNow = Calendar.getInstance();
int hour = rightNow.get(Calendar.HOUR_OF_DAY);
int min = rightNow.get(Calendar.MINUTE);
int sec = rightNow.get(Calendar.SECOND);
int hourmasuk;
int minmasuk;
int secmasuk;
public void printKeluar()
{
System.out.println("######################");
System.out.println("#####Resi Keluar#####");
System.out.println("#####Waktu Masuk#####");
System.out.println("###### "+String.format("%02d",hourmasuk)+":"+String.format("%02d",minmasuk)+":"+String.format("%02d",secmasuk)+" ######");
System.out.println("#####Waktu Keluar#####");
System.out.println("###### "+String.format("%02d",hour)+":"+String.format("%02d",min)+":"+String.format("%02d",sec)+" ######");
System.out.println("#Nomor Polisi "+nopol+"#");
System.out.println("#####Harga: "+price+"#####");
System.out.println("#####Terima Kasih#####");
System.out.println("######################");
System.out.println();
}
}
Komentar
Posting Komentar