Sistem Parkir Elektronik
Nama : Timothyus Tanner
NRP : 05111740000103
Kelas : PBO - A
Source Code
1. Parkir_Meter
/**
* Sistem Parkir Elektronik
*
* Nama : Timothyus Tanner
* NRP : 05111740000103
* Kelas : PBO - A
*/
import java.util.Scanner;
public class Parkir_Meter
{
public static void main()
{
Scanner scan = new Scanner(System.in);
System.out.println("Masukkan saldo anda");
int saldo = scan.nextInt();
System.out.print('\u000C');
System.out.println("Pilih Jenis Kendaraan Anda");
System.out.println("1. Mobil");
System.out.println("2. Motor");
int pilih;
pilih = scan.nextInt();
System.out.print('\u000C');
if(pilih == 1)
{
Mobil mobil = new Mobil();
mobil.NomorPlat();
System.out.print('\u000C');
mobil.print(saldo);
}
else if(pilih == 2)
{
Motor motor = new Motor();
motor.NomorPlat();
System.out.print('\u000C');
motor.print(saldo);
}
}
}
2. Mobil
/**
* Sistem Parkir Elektronik
*
* Nama : Timothyus Tanner
* NRP : 05111740000103
* Kelas : PBO - A
*/
import java.util.Scanner;
public class Mobil
{
Scanner scan = new Scanner(System.in);
String input;
int jam, total;
public String NomorPlat()
{
System.out.println("Silahkan Masukkan Nomor Plat Anda");
input = scan.nextLine();
return input;
}
public int durasi()
{
System.out.println("Silahkan masukkan durasi");
System.out.println("(Durasi dalam satuan jam)");
jam = scan.nextInt();
jam = jam / 24 + 1;
return jam;
}
public int jumlah()
{
total = durasi();
System.out.print('\u000C');
System.out.println("Tempelkan kartu pembayaran untuk membayar");
total = total * 4000;
System.out.println("Total Pembayaran : " + total);
return total;
}
public void print(int saldo)
{
int tot = jumlah();
System.out.print('\u000C');
System.out.println("Silahkan ambil karcis anda");
System.out.println("-------------------------");
System.out.println("| Jenis Kendaraan : Mobil");
System.out.println("| Nomor Plat : " + input);
System.out.println("| Tarif parkir : " + tot);
System.out.println("| Sisa Saldo : " + (saldo - tot));
System.out.println("-------------------------");
}
}
3. Motor
/**
* Sistem Parkir Elektronik
*
* Nama : Timothyus Tanner
* NRP : 05111740000103
* Kelas : PBO - A
*/
import java.util.Scanner;
public class Motor
{
Scanner scan = new Scanner(System.in);
String input;
int jam, total;
public String NomorPlat()
{
System.out.println("Silahkan Masukkan Nomor Plat Anda");
input = scan.nextLine();
return input;
}
public int durasi()
{
System.out.println("Silahkan masukkan durasi");
System.out.println("(Durasi dalam satuan jam)");
jam = scan.nextInt();
jam = jam / 24 + 1;
return jam;
}
public int jumlah()
{
total = durasi();
System.out.print('\u000C');
System.out.println("Tempelkan kartu pembayaran untuk membayar");
total = total * 4000;
System.out.println("Total Pembayaran : " + total);
return total;
}
public void print(int saldo)
{
int tot = jumlah();
System.out.print('\u000C');
System.out.println("Silahkan ambil karcis anda");
System.out.println("-------------------------");
System.out.println("| Jenis Kendaraan : Motor");
System.out.println("| Nomor Plat : " + input);
System.out.println("| Tarif parkir : " + tot);
System.out.println("| Sisa Saldo : " + (saldo - tot));
System.out.println("-------------------------");
}
}
Screenshoot