Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can you please make uml class diagram for that code import java.io.BufferedReader; import java.io.InputStreamReader; public class TicketManagement { public static void main(String [] args){ try{

can you please make uml class diagram for that code
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class TicketManagement {
public static void main(String [] args){
try{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
ticketcount tc = new ticketcount();
//getting users name and amount of travelers
System.out.println("Hello,welcome to the Izmir Airport. Please enter your full name:");
String name = br.readLine();
System.out.println("How many tickets are you planning to buy? One person can buy max 4 ticket in one time. :");
int amount = Integer.parseInt(br.readLine());
if(amount>4||amount<1){
System.out.println("Max 4 tickets was possible. Your ticket amount has been initialized to 1. ");
amount=1;
}
tc.setName(name);
tc.setAmountoofTravellers(amount);
//loop until user opt to exit
while(true){
//print welcome message
System.out.print("Welcome to the Izmir Airport. Are you going to travel in (1)domestic or (2)international departures? ");
//get departure chaoice
int departureChoice = Integer.parseInt(br.readLine());
if(departureChoice == 2){
//international departure
int price = 0;
String[] listofCities = {"Los Angeles(Needs extra transfer flight from Berlin)","Berlin","Paris","London"};
System.out.println("Available flights : "+ listofCities[0]+", "+listofCities[1]+", "+listofCities[2]+", "+listofCities[3]);
System.out.print("Where you would like travel (1)LosAngeles or (2)Any Other? ");
System.out.println("Please enter valid option. Don't enter more than one nonvalid option.");
//get destination city
int cityChoice = Integer.parseInt(br.readLine());
//add price
if(cityChoice == 1)
price = 100;
else if (cityChoice==2)
price = 0;
else {
System.out.print("Enter valid choice :");
cityChoice = Integer.parseInt(br.readLine());
if(cityChoice == 1)
price = 100;
else if (cityChoice==2)
price = 0;
else{
System.out.println("Quitting from the system..");
break;
}
}
System.out.print("Is your trip going to be (1)one-way or (2)roundtrip? ");
//get trip choice
int tripChoice = Integer.parseInt(br.readLine());
//add price
if(tripChoice == 1)
price += 200;
else if(tripChoice == 2)
price += 300;
else{
System.out.print("Enter valid choice :");
tripChoice = Integer.parseInt(br.readLine());
if(tripChoice == 1)
price += 200;
else if(tripChoice == 2)
price += 300;
else{
System.out.println("Quitting from the system");
break;
}
}
System.out.print("What is your travel option (1)PM or (2)AM ?");
//get travel option
int travelOption = Integer.parseInt(br.readLine());
//add cost
if(travelOption == 1)
price +=10;
else if (travelOption == 2)
price += 20;
else{
System.out.print("Enter valid choice :");
travelOption = Integer.parseInt(br.readLine());
if(travelOption == 1)
price +=10;
else if (travelOption == 2)
price += 20;
else{
System.out.println("Quitting from the system");
break;
}
}
System.out.print("(1)Business Class Advantages: " +
"\t- Food Service " +
"\t- Smart TV " +
"\t- Unlimited coffee and tea " +
"\t- More free space " +
"\t- VIP transportation to airport " +
"(2)Economy Class Advantages: " +
"\t- Food Service " +
"\t- Smart TV " +
"Which class do you choose? ");
//get seat class
int seatClass = Integer.parseInt(br.readLine());
//add price
if(seatClass == 1)
price += 150;
else if(seatClass == 2)
price +=0;
else{
System.out.print("Enter valid choice :");
seatClass = Integer.parseInt(br.readLine());
if(seatClass == 1)
price += 150;
else if(seatClass == 2)
price +=0;
else{
System.out.println("Quiting from the system");
break;
}
}
//display total price
System.out.println("Dear "+ tc.getName()+", your total price is " + (price*tc.getAmountoofTravellers()) + " ");
System.out.print("Are you going to buy the ticket (1)yes or (2)no? ");
//get whether buy or not buy
int buyChoice = Integer.parseInt(br.readLine());
if(buyChoice == 1){
//buy the ticket and exit
System.out.println("Thank you for choosing us. Have a nice flight!");
break;
}
else{
//not buy ticket
System.out.print("Are you (1)Quitting the website or want to (2)Start again? ");
int userChoice = Integer.parseInt(br.readLine());
//exit
if(userChoice == 1)
break;
}
}
else if(departureChoice==1){
//domestic departure
System.out.print("Where you would like to travel? (Every city has the same price)");
//get destination city
String cityChoice = br.readLine();
//set price
int price = 0;
System.out.print("Is your trip to "+ cityChoice+ " going to be (1)One-way or (2)Roundtrip? ");
//get trip choice
int tripChoice = Integer.parseInt(br.readLine());
//add price
if(tripChoice == 1)
price += 150;
else if(tripChoice == 2)
price += 200;
else{
System.out.print("Enter valid choice :");
tripChoice = Integer.parseInt(br.readLine());
if(tripChoice == 1)
price += 150;
else if(tripChoice == 2)
price += 200;
else{
System.out.println("Quitting from the system.");
break;
}
}
System.out.print("What is your travel option (1)PM or (2)AM? ");
//get travel option
int travelOption = Integer.parseInt(br.readLine());
//add price
if(travelOption == 1)
price +=30;
else if(travelOption == 2)
price +=0;
else{
System.out.print("Enter valid choice :");
travelOption = Integer.parseInt(br.readLine());
if(travelOption == 1)
price +=30;
else if(travelOption == 2)
price +=0;
else{
System.out.println("Quitting from the system");
break;
}
}
System.out.print("(1)Business Class Advantages: " +
"\t- Food Service " +
"\t- Smart TV " +
"\t- Unlimited coffee and tea " +
"\t- More free space " +
"\t- VIP transportation to airport " +
"(2)Economy Class Advantages: " +
"\t- Food Service " +
"\t- Smart TV " +
"Which class do you choose? ");
//get seat class
int seatClass = Integer.parseInt(br.readLine());
//add price
if(seatClass == 1)
price += 200;
else if(seatClass == 2)
price += 0;
else{
System.out.print("Enter valid choice :");
seatClass = Integer.parseInt(br.readLine());
if(seatClass == 1)
price += 200;
else if(seatClass == 2)
price += 0;
else{
System.out.println("Quitting from the system.");
break;
}
}
//display total price
System.out.println("Dear "+ tc.getName()+", your total price is " + (price*tc.getAmountoofTravellers()) + " TL");
System.out.print("Are you going to buy the ticket (1)yes or (2)no? ");
//get if buy or not buy
int buyChoice = Integer.parseInt(br.readLine());
if(buyChoice == 1){
//buy ticket and exit
System.out.println("Thank you for choosing us. Have a nice flight!");
break;
}
else{
//not buy ticket
System.out.print("Are you (1)Quitting the website or want to (2)Start again? ");
int userChoice = Integer.parseInt(br.readLine());
if(userChoice == 1)
break;
}
}
else{
System.out.println("Please enter valid option");
}
}
br.close();
}
catch(Exception e){
e.printStackTrace();
}
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions