Commit 0af9c23d authored by Tom's avatar Tom

Final Version of code

parent 1a42f6d2
......@@ -20,6 +20,8 @@ public class Airplane_class {
//this int is for choosing a seat
int seat;
int end;
//Here I start a loop so that I can transfer the user back to here when needed
......@@ -72,18 +74,66 @@ public class Airplane_class {
//This prints a sentence to the screen
System.out.println("\n\n\n\n\n\nYou have chosen First Class\n");
System.out.println("Would you like to choose a seat? type y for yes or n for no ");
//This allows the user to enter a letter
yesOrNo = input.next();
//if the user entered y, the following code will take place
if (yesOrNo.equals("y")) {
System.out.println("Please select a seat between 1-18, enter then number of the seat you would like\n");
//Allows the user to input the seat they want
seat = input.nextInt();
System.out.println("You chose seat number " + seat + "!");
//This checks to see if the seat is within the parameters
if (seat < 19 && seat > 0 ) {
System.out.print("\n\n\n\n\n\n\nThank you for flying with us today, here is your boarding pass\n\n"
+ "---Boarding Pass---"
+ "\nName : " + name
+ "\nFrom : " + origin
+ "\nTo : " + destination
+ "\nFlight : FL" + FL
+ "\nSeat No : " + seat
+ "\nSection : First Class\n\n\n\n\n\n");
System.out.print("\nEnter 1 to book another flight or press 2 to end application\n\n");
end=input.nextInt();
//checks if the user entered 2, if they did the program will close
if (end==2) {
return;
}
//if the if statement from earlier (the parameter checking one) finds that the selected seat is not in the
//parameter, the else statement will run, this displays a message and ends the program
}else {
System.out.println("Seat not within parameters");
return;
}
}
//if the yerOrNo input equals n, the following code will run
if (yesOrNo.equals("n")) {
System.out.println("you chose no");
seat = 0;
seat ++;
System.out.print("\n\n\n\n\n\n\nThank you for flying with us today, here is your boarding pass\n\n"
+ "---Boarding Pass---"
+ "\nName : " + name
+ "\nFrom : " + origin
+ "\nTo : " + destination
+ "\nFlight : FL" + FL
+ "\nSeat No : " + seat
+ "\nSection : First Class\n\n\n\n\n\n");
System.out.print("\nEnter 1 to book another flight or press 2 to end application\n\n");
//Allows the user to input a numerical value
end=input.nextInt();
//if the user input is equal to 2, the program will close
if (end==2) {
return;
}
}
......@@ -93,12 +143,131 @@ public class Airplane_class {
break;
//My second case is for the business section of the plane
case 2:
System.out.println("\\n\\n\\n\\n\\n\\nYou have chosen Business");
System.out.println("\n\n\n\n\n\nYou have chosen Business");
System.out.println("Would you like to choose a seat? type y for yes or n for no ");
//Allows the user to input a string
yesOrNo = input.next();
//if the condition is met the following code will run
if (yesOrNo.equals("y")) {
//Allows the user to enter a seat number, if the seat number is within the chosen parameters, the code if statement will run
System.out.println("Please select a seat between 19-45, enter then number of the seat you would like\n");
seat = input.nextInt();
if (seat < 46 && seat > 18 ) {
System.out.print("\n\n\n\n\n\n\nThank you for flying with us today, here is your boarding pass\n\n"
+ "---Boarding Pass---"
+ "\nName : " + name
+ "\nFrom : " + origin
+ "\nTo : " + destination
+ "\nFlight : FL" + FL
+ "\nSeat No : " + seat
+ "\nSection : Business\n\n\n\n\n\n");
//Allows the user to end a number, this decides if the user will book another flight or close the program
System.out.print("\nEnter 1 to book another flight or press 2 to end application\n\n");
end=input.nextInt();
if (end==2) {
return;
}
//If the number entered earlier is not within the parameters then the program will end
}else {
System.out.println("Seat not within parameters");
return;
}
}
//If the user entered n in the earlier choice this screen will be displayed, here the seat value is set to 18 and then
//is added to by 1 every time this code is gone through
if (yesOrNo.equals("n")) {
seat = 18;
seat ++;
System.out.print("\n\n\n\n\n\n\nThank you for flying with us today, here is your boarding pass\n\n"
+ "---Boarding Pass---"
+ "\nName : " + name
+ "\nFrom : " + origin
+ "\nTo : " + destination
+ "\nFlight : FL" + FL
+ "\nSeat No : " + seat
+ "\nSection : First Class\n\n\n\n\n\n");
System.out.print("\nEnter 1 to book another flight or press 2 to end application\n\n");
end=input.nextInt();
if (end==2) {
return;
}
}
break;
//This case is used for the economy section of the plane
case 3:
System.out.println("\n\n\n\n\n\nYou have chosen Economy");
System.out.println("Would you like to choose a seat? type y for yes or n for no ");
//The user is prompted to enter a letter, if the letter is y the following code runs
yesOrNo = input.next();
if (yesOrNo.equals("y")) {
System.out.println("Please select a seat between 46-70, enter then number of the seat you would like\n");
//This allows the user to enter a numerical value to choose a seat number, if the seat number chosen is within the
//parameter, the following if statement plays
seat = input.nextInt();
if (seat < 71 && seat > 45 ) {
System.out.print("\n\n\n\n\n\n\nThank you for flying with us today, here is your boarding pass\n\n"
+ "---Boarding Pass---"
+ "\nName : " + name
+ "\nFrom : " + origin
+ "\nTo : " + destination
+ "\nFlight : FL" + FL
+ "\nSeat No : " + seat
+ "\nSection : Economy\n\n\n\n\n\n");
System.out.print("\nEnter 1 to book another flight or press 2 to end application\n\n");
//This allows the user to enter a digit to decide if the would like to make another booking or just close the application
//If two is entered, the application will close, if one is entered, the code will start from the beginning
end=input.nextInt();
if (end==2) {
return;
}
}else {
System.out.println("Seat not within parameters");
return;
}
}
//This if statement is run if the user entered n instead of y earlier
if (yesOrNo.equals("n")) {
seat = 45;
seat ++;
System.out.print("\n\n\n\n\n\n\nThank you for flying with us today, here is your boarding pass\n\n"
+ "---Boarding Pass---"
+ "\nName : " + name
+ "\nFrom : " + origin
+ "\nTo : " + destination
+ "\nFlight : FL" + FL
+ "\nSeat No : " + seat
+ "\nSection : First Class\n\n\n\n\n\n");
System.out.print("\nEnter 1 to book another flight or press 2 to end application\n\n");
end=input.nextInt();
if (end==2) {
return;
}
}
break;
......
......@@ -5,11 +5,13 @@ public class test {
public static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
// TODO Auto-generated method stub
int day;
day =input.nextInt();
switch (day) {
......@@ -17,8 +19,7 @@ public class test {
}
switch (day) {
case 1:
System.out.println("Monddsd");
break;
case 2:
System.out.println("Msdsdsdsdsddsd");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment