Commit c68cdefd authored by jordan.perrin's avatar jordan.perrin

the whole thing so far

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>AirlineReservation</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
import java.util.Scanner;
import java.util.Random;
public class AirlineReservation {
public static void main(String[] args) {
// TODO Auto-generated method stub
// Write an application to assign seats on each flight of the airplane.
// Each flight has 90 seats.
// Ask their name, origin city, destination city.
Scanner input1 = new Scanner(System.in);
String name, origin, destination;
System.out.println("Please enter your name: ");
name = input1.next();
System.out.println("Please enter your origin city: ");
origin = input1.next();
System.out.println("Please enter your destination city: ");
destination = input1.next();
// System then generates flight number, FL01 through FL28.
Random rand = new Random();
int flightno = rand.nextInt(29);
while (flightno==0) {
rand.nextInt(29);
}
System.out.println("Your flight number is: " + flightno);
// One flight every six hours, 28 flights each week.
// Then display the following options
System.out.println("Please type 1 for First Class");
System.out.println("Please type 2 for Business Class");
System.out.println("Please type 3 for Economy Class");
// Please type 1 for First Class
// Please type 2 for Business
// Please type 3 for Economy
double FirstClass, BusinessClass, EconomyClass;
FirstClass = 1;
BusinessClass = 2;
EconomyClass = 3;
double FlightClass = input1.nextDouble();
if (FlightClass == FirstClass) {
System.out.println("Thank you for choosing First Class.");
}
if (FlightClass == BusinessClass) {
System.out.println("Thank you for choosing Business Class.");
}
if (FlightClass == EconomyClass) {
System.out.println("Thank you for choosing Economy Class.");
}
// The user can then choose to pick a seat number from the unassigned seats, if they don't one is assigned randomly
// Typing 1 gives the user a seat between 1-18
// Typing 2 gives the user a seat between 19-45
// Typing 3 gives the user a seat between 46-90
if (FlightClass == FirstClass) {
int seatno = rand.nextInt(18 - 1 + 1) + 1;
System.out.println("Your seat number is: " + seatno);
}
if (FlightClass == BusinessClass) {
int seatno = rand.nextInt(45 - 19 + 1) + 19;
System.out.println("Your seat number is: " + seatno);
}
if (FlightClass == EconomyClass) {
int seatno = rand.nextInt(90 - 46 + 1) + 46;
System.out.println("Your seat number is: " + seatno);
}
// Display a seating chart using an array, using a 9x10 chart.
// After a seat is assigned, replace the seat number with XX in the array.
// [XX][XX][XX] [04][05][06] [07][08][09]
// [XX][XX][XX] [13][14][15] [16][17][18]
//
// [XX][XX][XX] [XX][XX][XX] [XX][XX][XX]
// [XX][XX][30] [31][32][33] [34][35][36]
// [XX][38][XX] [40][41][42] [43][44][45]
//
// [XX][XX][XX] [XX][XX][XX] [XX][XX][XX]
// [55][56][57] [58][59][60] [61][62][63]
// [XX][XX][XX] [67][68][69] [70][71][72]
// [XX][XX][XX] [XX][XX][XX] [XX][80][81]
// [82][83][XX] [85][86][XX] [88][89][90]
// XX means the seat is unavailable, do not assign another person there.
// When a section is completely full, ask the user if they would like to be placed in First/Business instead
// If yes, they are assigned a seat in one of the sections.
// If no, display this message:
// "Sorry, there is no available seating at the moment, next flight leaves in 6 hours."
// Print a boarding pass for them indicating name, origin city, destination city, flight number, seat number, and class.
// Print the seating array after.
}
}
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