ETS PBO E-Parking
Main Class
import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
Scanner scan= new Scanner(System.in);
int cost;
int jenis;
int bayar;
Pembayaran parkir = new Pembayaran();
System.out.println("Pilih jenis kendaraan:");
System.out.println("1. Mobil");
System.out.println("2. Motor \n");
jenis=scan.nextInt();
System.out.println("Silakan Masukkan Plat Nomor Anda \n");
parkir.getnopol();
Pembayaran ticket=new Pembayaran();
System.out.println("1. Dapatkan Harga");
System.out.println("2. Print Tiket\n");
bayar=scan.nextInt();
switch(bayar)
{
case 1:
cost=ticket.getCost();
System.out.println(cost);
break;
case 2:
ticket.printTicket();
break;
}
switch(jenis)
{
case 1:
cost=3000;
System.out.println("|Harga Tiket :Rp" +cost+",00");
break;
case 2:
cost=2000;
System.out.println("|Harga Tiket :Rp" +cost+",00");
break;
}
}
}
Pembayaran Class
import java.util.Scanner;
public class Pembayaran
{
public int cost;
private int total;
private static String Nopol;
Scanner scan= new Scanner(System.in);
public Pembayaran()
{
cost = 0; //inisialisasi
}
public int getCost()
{
return cost;
}
public void getnopol(){
Nopol = scan.nextLine();
}
public void printTicket()
{
System.out.println(" ============================ ");
System.out.println("{ Pemerintah Kota Surabayah }");
System.out.println(" ============================ ");
System.out.println("| Ini Tiket Anda |");
System.out.println("| Dijaga Baik baik ea |");
System.out.println("|Dengan plat nomor :" +Nopol + " " );
}
}
Komentar
Posting Komentar