Class Main
import java.util.Scanner;
/**
* Write a description of class Main here.
*
* @author (Ismail)
* @version (15102018)
*/
public class Main
{
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
int menu, harga;
harga = 2000;
SistemParkir tiket = new SistemParkir(harga);
System.out.println("Silahkan pilih tombol yang di inginkan \n");
System.out.println("Pos Masuk Parkir");
System.out.println("1. Parkir");
System.out.println("2. Bantuan\n");
System.out.println("Pos Keluar Parkir");
System.out.println("3. Scan Barcode Keluar");
System.out.println("4. Print Bukti Parkir");
int tipe=1;
while(tipe == 1)
{
menu = scan.nextInt();
switch(menu)
{
case 1:
System.out.println("Masukkan Waktu Parkir (contoh : 1700) : ");
int awal = scan.nextInt();
tiket.masukparkir(awal);
tiket.Tiketparkir();
break;
case 2:
System.out.println("Harap menunggu operator");
break;
case 3:
System.out.println("Masukkan Waktu Keluar Parkir (contoh 1800) : ");
int akhir = scan.nextInt();
tiket.keluarparkir(akhir);
tiket.Scanbarcode();
break;
case 4:
tiket.buktiparkir();
tipe=0;
break;
}
}
}
}
Class SistemParkir
/**
* Write a description of class SistemParkir here.
*
* @author (Ismail)
* @version (16102018)
*/
public class SistemParkir
{
private int tiket;
private int masuk;
private int biaya;
private int keluar;
public SistemParkir(int harga)
{
masuk = 0;
biaya = harga;
}
public void Tiketparkir()
{
System.out.println("##############");
System.out.println("Selamat Datang");
System.out.println("Waktu Parkir : "+masuk);
System.out.println("############");
}
public int masukparkir(int awal)
{
return masuk=awal;
}
public void keluarparkir(int akhir)
{
keluar = akhir;
akhir -= masuk;
akhir = akhir/1000;
biaya += akhir*1000;
}
public void Scanbarcode()
{
System.out.println("Biaya Parkir : Rp "+biaya);
}
public void buktiparkir()
{
System.out.println("#############");
System.out.println("Selamat Jalan");
System.out.println("Bukti Parkir");
System.out.println("Jam Parkir : "+masuk);
System.out.println("Jam Keluar : "+keluar);
System.out.println("Rp. "+biaya);
System.out.println("#############");
}
}