Cara Membuat Program Hotel Paris Sederhana Dengan NetBeans
Nama :moh.alfarisyi
Nim :161011400133
Assalamualaikum Wr.Wb
Assalamualaikum Wr.Wb
Pada kali ini saya mau share contoh program sederhana tentang aplikasi Hotel dalam program java menggunakan Netbeans IDE8.2
untuk pertama-tama saya akan menggambarkan cara program aplikasi hotel tersebut menggunakan flowchart seperti yang dibawah ini ;
untuk pertama-tama saya akan menggambarkan cara program aplikasi hotel tersebut menggunakan flowchart seperti yang dibawah ini ;
Untuk Memulai program yang akan dibuat bukalah JavaNetbeans pada PC/laptop
kemudian
Pilih File >> New Project >> Java >> Java Application
>> kemudian beri nama "SewaHotel". Setelah itu akan secara langsung
masuk pada Source code javanya. Pada source codenya masukan codingan
seperti contoh berikut :
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package sewahotel;
/**
*
* @author Awien
*/
import java.io.*;
public class SewaHotel {
/**
* @param args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
String nama="",kamar="";
int jenis=0,status=0,lama=0,tarif=0;
double diskon=0,bayar=0;
BufferedReader br = new BufferedReader(new InputStreamReader (System.in));
//input
System.out.println("--**-- HOTEL PARIS --**--");
System.out.print("Nama Pelanggan \t\t\t: ");
nama = br.readLine();
System.out.println("\nPilih Jenis Kamar Hotel");
System.out.println("1. Dove Room Rp 275.000/hari");
System.out.println("2. Clear Room Rp 300.000/hari");
System.out.println("3. President Room Rp 370.000/hari");
System.out.print("Jenis kamar yang dipesan \t: ");
jenis = Integer.parseInt(br.readLine());
System.out.print("\nLama Menginap \t\t\t: ");
lama = Integer.parseInt(br.readLine());
System.out.println("\nStatus Pelanggan");
System.out.println("1. Member");
System.out.println("2. Non Member");
System.out.print("Pilih status pelanggan \t\t: ");
status = Integer.parseInt(br.readLine());
//proses perhitungan
switch (jenis) {
case 1:
tarif = lama*275000;
kamar="Dove Room";
break;
case 2:
tarif = lama*300000;
kamar="Clear Room";
break;
case 3:
tarif = lama*375000;
kamar="President Room";
break;
default:
break;
}
if (status==1){
if(lama>=4 && lama<=7){
diskon = 0.20 * tarif;
}else if (lama>7) {
diskon = 0.35 * tarif;
}
}else if (status==2){
if (lama>=4 && lama<=7){
diskon = 0.10 * tarif;
}else if (lama>7){
diskon = 0.15 * tarif;
}
}
bayar = tarif-diskon;
//output
System.out.println("\n\n---***--- NOTA PEMBAYARAN PARIS HOTEL ---***---");
System.out.println("Nama Pelanggan \t\t\t: " + nama);
System.out.println("Jenis Kamar \t\t\t: " + kamar);
System.out.println("Tarif Penginapan \t\t: Rp " + tarif + ",-");
System.out.println("Diskon Menginap \t\t: Rp " + diskon + ",-");
System.out.println("Nominal yang harus dibayar \t: Rp " + bayar + ",-");
System.out.println("====================================================");
}
}
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package sewahotel;
/**
*
* @author Awien
*/
import java.io.*;
public class SewaHotel {
/**
* @param args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
String nama="",kamar="";
int jenis=0,status=0,lama=0,tarif=0;
double diskon=0,bayar=0;
BufferedReader br = new BufferedReader(new InputStreamReader (System.in));
//input
System.out.println("--**-- HOTEL PARIS --**--");
System.out.print("Nama Pelanggan \t\t\t: ");
nama = br.readLine();
System.out.println("\nPilih Jenis Kamar Hotel");
System.out.println("1. Dove Room Rp 275.000/hari");
System.out.println("2. Clear Room Rp 300.000/hari");
System.out.println("3. President Room Rp 370.000/hari");
System.out.print("Jenis kamar yang dipesan \t: ");
jenis = Integer.parseInt(br.readLine());
System.out.print("\nLama Menginap \t\t\t: ");
lama = Integer.parseInt(br.readLine());
System.out.println("\nStatus Pelanggan");
System.out.println("1. Member");
System.out.println("2. Non Member");
System.out.print("Pilih status pelanggan \t\t: ");
status = Integer.parseInt(br.readLine());
//proses perhitungan
switch (jenis) {
case 1:
tarif = lama*275000;
kamar="Dove Room";
break;
case 2:
tarif = lama*300000;
kamar="Clear Room";
break;
case 3:
tarif = lama*375000;
kamar="President Room";
break;
default:
break;
}
if (status==1){
if(lama>=4 && lama<=7){
diskon = 0.20 * tarif;
}else if (lama>7) {
diskon = 0.35 * tarif;
}
}else if (status==2){
if (lama>=4 && lama<=7){
diskon = 0.10 * tarif;
}else if (lama>7){
diskon = 0.15 * tarif;
}
}
bayar = tarif-diskon;
//output
System.out.println("\n\n---***--- NOTA PEMBAYARAN PARIS HOTEL ---***---");
System.out.println("Nama Pelanggan \t\t\t: " + nama);
System.out.println("Jenis Kamar \t\t\t: " + kamar);
System.out.println("Tarif Penginapan \t\t: Rp " + tarif + ",-");
System.out.println("Diskon Menginap \t\t: Rp " + diskon + ",-");
System.out.println("Nominal yang harus dibayar \t: Rp " + bayar + ",-");
System.out.println("====================================================");
}
}
Setelah memasukan contoh codingan pada source code java, kemudian pilih
menu Run >> Run Program atau Shift + f6 untuk menjakan programnya.
Pada saat program berjalan dengan baik, maka tampilan program tersebut akan seperti berikut :
Wassalammuaikum Wr.Wb


Tidak ada komentar:
Posting Komentar