Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AirlineReservation
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jordan.perrin
AirlineReservation
Commits
c68cdefd
Commit
c68cdefd
authored
Nov 03, 2019
by
jordan.perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
the whole thing so far
parents
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
149 additions
and
0 deletions
+149
-0
.classpath
AirlineReservation/.classpath
+6
-0
.gitignore
AirlineReservation/.gitignore
+1
-0
.project
AirlineReservation/.project
+17
-0
org.eclipse.jdt.core.prefs
AirlineReservation/.settings/org.eclipse.jdt.core.prefs
+11
-0
AirlineReservation.java
AirlineReservation/src/AirlineReservation.java
+114
-0
No files found.
AirlineReservation/.classpath
0 → 100644
View file @
c68cdefd
<?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>
AirlineReservation/.gitignore
0 → 100644
View file @
c68cdefd
/bin/
AirlineReservation/.project
0 → 100644
View file @
c68cdefd
<?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>
AirlineReservation/.settings/org.eclipse.jdt.core.prefs
0 → 100644
View file @
c68cdefd
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
AirlineReservation/src/AirlineReservation.java
0 → 100644
View file @
c68cdefd
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.
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment