SlideShare a Scribd company logo
import java.util.Scanner;
public class Session03
{
//static String nama;
static String nama, jurusan, kelas;
static int pilih, tipe, jumlah, harga;
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.printf("%60sn","BEGH Train Reservation Ticket");
System.out.println("Welcome,");
System.out.print("Please, input your name = ");
nama = in.nextLine();
System.out.println("nChoose Destination :");
System.out.println("1. Bandung");
System.out.println("2. Yogyakarta");
System.out.println("3. Semarang");
System.out.println("4. Surabaya");
System.out.print("nPlease input your choice = ");
pilih = in.nextInt();
in.nextLine();
if(pilih == 1 || pilih == 2 || pilih == 3 || pilih == 4){
switch(pilih){
case 1 :
System.out.println("1. Business =
Rp.50.000tRemaining Ticket = 30");
System.out.println("2. Executive =
Rp.80.000tRemaining Ticket = 40");
jurusan="Bandung";
break;
case 2 :
System.out.println("1. Business =
Rp.70.000tRemaining Ticket = 30");
System.out.println("2. Executive =
Rp.100.000tRemaining Ticket = 40");
jurusan="Yogyakarta";
break;
case 3 :
System.out.println("1. Business =
Rp.90.000tRemaining Ticket = 30");
System.out.println("2. Executive =
Rp.120.000tRemaining Ticket = 40");
jurusan="Semarang";
break;
case 4 :
System.out.println("1. Business =
Rp.100.000tRemaining Ticket = 30");
System.out.println("2. Executive =
Rp.130.000tRemaining Ticket = 40");
jurusan="Surabaya";
break;
}
System.out.print("nPlease input Your choice = ");
tipe = in.nextInt();
in.nextLine();
if(tipe==1 || tipe==2)
{
kelas = (tipe==1) ? "Business" : "Executive";
System.out.print("nPlease input number of Ticket you
want to book = ");
jumlah=in.nextInt();
in.nextLine();
switch(pilih){
case 1:
harga= (tipe==1) ? 50000 : 80000;
break;
case 2:
harga= (tipe==1) ? 70000 : 100000;
break;
case 3:
harga= (tipe==1) ? 90000 : 120000;
break;
case 4:
harga= (tipe==1) ? 100000 : 130000;
break;
}
if((tipe==1 && jumlah>30) || (tipe==2 && jumlah>40))
{
System.out.println("nnnnSorry, The number of
Ticket you ordered exceeded our ability");
}
else
{
System.out.println("nnnnThank You Mr/Mrs " +
nama);
System.out.println("nThis is your purchase
invoice");
System.out.println("n Purchase
Invoice");
System.out.println("nDestination : " +
jurusan);
System.out.println("Class : " + kelas);
System.out.println("Price : " + harga);
System.out.println("Ticket(s) : " + jumlah);
System.out.println("nTotal Purchase : " + (harga
* jumlah));
}
}else{
System.out.println("Wrong Input!");
in.nextLine();
}
}else{
System.out.println("Wrong Input!");
in.nextLine();
}
System.out.println("nnnn ^__^Thank You For Your Purchase in
Our Transportation Services^__^nnnn");
in.nextLine();
}
}

More Related Content

PPT
Java Methods - An Introduction to Software Development
TXT
Code
TXT
Code javascript
PDF
StudentData.javaimport java.util.Scanner; public class Student.pdf
DOCX
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
DOCX
How to get input from usjer in Java.docx
PDF
CountStringCharacters.javaimport java.util.Scanner; public cla.pdf
DOCX
Star pattern programs in java Print Star pattern in java and print triangle ...
Java Methods - An Introduction to Software Development
Code
Code javascript
StudentData.javaimport java.util.Scanner; public class Student.pdf
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
How to get input from usjer in Java.docx
CountStringCharacters.javaimport java.util.Scanner; public cla.pdf
Star pattern programs in java Print Star pattern in java and print triangle ...

Similar to Code (14)

PPTX
JAVA Question : Programming Assignment
PPTX
Lab101.pptx
PDF
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
PPTX
Computer programming 2 chapter 1-lesson 2
DOCX
Import java
DOCX
WAP to implement inheritance and overloading methods in java
PPT
07-Basic-Input-Output.ppt
DOCX
Java Practical1 based on Basic assignment
PPTX
java input & output statements
DOCX
PPTX
Lab01.pptx
DOCX
Quest 1 define a class batsman with the following specifications
PPTX
The definitive guide to java agents
DOCX
Java file
JAVA Question : Programming Assignment
Lab101.pptx
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
Computer programming 2 chapter 1-lesson 2
Import java
WAP to implement inheritance and overloading methods in java
07-Basic-Input-Output.ppt
Java Practical1 based on Basic assignment
java input & output statements
Lab01.pptx
Quest 1 define a class batsman with the following specifications
The definitive guide to java agents
Java file
Ad

More from Ray Ray (6)

TXT
Booklab
TXT
Booklab
TXT
Booklab
TXT
Code
TXT
Code
DOCX
Laporan Counting Grade Apps
Booklab
Booklab
Booklab
Code
Code
Laporan Counting Grade Apps
Ad

Recently uploaded (20)

PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
01-Introduction-to-Information-Management.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
RMMM.pdf make it easy to upload and study
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
Trump Administration's workforce development strategy
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Cell Types and Its function , kingdom of life
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Anesthesia in Laparoscopic Surgery in India
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
STATICS OF THE RIGID BODIES Hibbelers.pdf
01-Introduction-to-Information-Management.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
RMMM.pdf make it easy to upload and study
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Weekly quiz Compilation Jan -July 25.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Orientation - ARALprogram of Deped to the Parents.pptx
Trump Administration's workforce development strategy
A systematic review of self-coping strategies used by university students to ...
Cell Types and Its function , kingdom of life
Final Presentation General Medicine 03-08-2024.pptx
Complications of Minimal Access Surgery at WLH
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
GDM (1) (1).pptx small presentation for students
Anesthesia in Laparoscopic Surgery in India

Code

  • 1. import java.util.Scanner; public class Session03 { //static String nama; static String nama, jurusan, kelas; static int pilih, tipe, jumlah, harga; public static void main(String args[]) { Scanner in = new Scanner(System.in); System.out.printf("%60sn","BEGH Train Reservation Ticket"); System.out.println("Welcome,"); System.out.print("Please, input your name = "); nama = in.nextLine(); System.out.println("nChoose Destination :"); System.out.println("1. Bandung"); System.out.println("2. Yogyakarta"); System.out.println("3. Semarang"); System.out.println("4. Surabaya"); System.out.print("nPlease input your choice = "); pilih = in.nextInt(); in.nextLine(); if(pilih == 1 || pilih == 2 || pilih == 3 || pilih == 4){ switch(pilih){ case 1 : System.out.println("1. Business = Rp.50.000tRemaining Ticket = 30"); System.out.println("2. Executive = Rp.80.000tRemaining Ticket = 40"); jurusan="Bandung"; break; case 2 : System.out.println("1. Business = Rp.70.000tRemaining Ticket = 30"); System.out.println("2. Executive = Rp.100.000tRemaining Ticket = 40"); jurusan="Yogyakarta"; break; case 3 : System.out.println("1. Business = Rp.90.000tRemaining Ticket = 30"); System.out.println("2. Executive = Rp.120.000tRemaining Ticket = 40"); jurusan="Semarang"; break; case 4 : System.out.println("1. Business = Rp.100.000tRemaining Ticket = 30"); System.out.println("2. Executive = Rp.130.000tRemaining Ticket = 40"); jurusan="Surabaya"; break; } System.out.print("nPlease input Your choice = "); tipe = in.nextInt(); in.nextLine(); if(tipe==1 || tipe==2)
  • 2. { kelas = (tipe==1) ? "Business" : "Executive"; System.out.print("nPlease input number of Ticket you want to book = "); jumlah=in.nextInt(); in.nextLine(); switch(pilih){ case 1: harga= (tipe==1) ? 50000 : 80000; break; case 2: harga= (tipe==1) ? 70000 : 100000; break; case 3: harga= (tipe==1) ? 90000 : 120000; break; case 4: harga= (tipe==1) ? 100000 : 130000; break; } if((tipe==1 && jumlah>30) || (tipe==2 && jumlah>40)) { System.out.println("nnnnSorry, The number of Ticket you ordered exceeded our ability"); } else { System.out.println("nnnnThank You Mr/Mrs " + nama); System.out.println("nThis is your purchase invoice"); System.out.println("n Purchase Invoice"); System.out.println("nDestination : " + jurusan); System.out.println("Class : " + kelas); System.out.println("Price : " + harga); System.out.println("Ticket(s) : " + jumlah); System.out.println("nTotal Purchase : " + (harga * jumlah)); } }else{ System.out.println("Wrong Input!"); in.nextLine(); } }else{ System.out.println("Wrong Input!"); in.nextLine(); } System.out.println("nnnn ^__^Thank You For Your Purchase in Our Transportation Services^__^nnnn"); in.nextLine(); } }