e-parking system - PBO A
SOURCE CODE :
1. Class epark(main) :
import java.util.Scanner;
public class epark
{
private static int price,durasi;
private static String jenis,plat;
public static void main()
{
Scanner scan= new Scanner(System.in);
kendaraan vehicle; vehicle = new kendaraan();
System.out.println("Pilih jenis kendaraan (Motor/Mobil)");
jenis = vehicle.getJenis();
System.out.println("Masukkan nomor plat");
plat = vehicle.getNopol();
System.out.println("Masukkan durasi parkir yang di inginkan (Dalam jam)");
durasi = scan.nextInt();
if(jenis.contains("motor")){
price = durasi*100;}
else if(jenis.contains("mobil")){
price = durasi*3000;}
printTicket();
}
public static void printTicket(){
System.out.println("\nTiket Parkir\n");
System.out.println("Jenis kendaraan : "+jenis);
System.out.println("plat nomor : "+plat);
System.out.println("Durasi parkir : "+durasi+" jam");
System.out.println("Biaya : "+price);}
}
2. Class kendaraan :
import java.util.*;
public class kendaraan
{
Scanner scan = new Scanner(System.in);
private String jenis;
private String plat;
public String getJenis()
{
jenis = scan.nextLine();
return jenis;}
public String getNopol()
{
plat = scan.nextLine();
return plat;}
}
Komentar
Posting Komentar