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
hayden.gooi
AirlineReservation
Commits
1a2e034b
Commit
1a2e034b
authored
Nov 02, 2019
by
User
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
options
parent
c44069e2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
2 deletions
+44
-2
reservation.java
src/airlinereservation/reservation.java
+44
-2
No files found.
src/airlinereservation/reservation.java
View file @
1a2e034b
...
@@ -5,7 +5,7 @@ public class reservation {
...
@@ -5,7 +5,7 @@ public class reservation {
public
static
void
main
(
String
[]
args
)
{
//main subprogram
public
static
void
main
(
String
[]
args
)
{
//main subprogram
Scanner
input
=
new
Scanner
(
System
.
in
);
Scanner
input
=
new
Scanner
(
System
.
in
);
int
choice
=
0
;
int
choice
=
0
;
String
plane
[][]
=
{{
"
01"
,
"02"
,
"03
"
},
{
"04"
,
"05"
,
"06"
},
{
"07"
,
"08"
,
"09"
},
//initialise the array which contains the plane seats
String
plane
[][]
=
{{
"
XX"
,
"02"
,
"XX
"
},
{
"04"
,
"05"
,
"06"
},
{
"07"
,
"08"
,
"09"
},
//initialise the array which contains the plane seats
{
"10"
,
"11"
,
"12"
},
{
"13"
,
"14"
,
"15"
},
{
"16"
,
"17"
,
"18"
},
{
"10"
,
"11"
,
"12"
},
{
"13"
,
"14"
,
"15"
},
{
"16"
,
"17"
,
"18"
},
{
"19"
,
"20"
,
"21"
},
{
"22"
,
"23"
,
"24"
},
{
"25"
,
"26"
,
"27"
},
{
"19"
,
"20"
,
"21"
},
{
"22"
,
"23"
,
"24"
},
{
"25"
,
"26"
,
"27"
},
{
"28"
,
"29"
,
"30"
},
{
"31"
,
"32"
,
"33"
},
{
"34"
,
"35"
,
"36"
},
{
"28"
,
"29"
,
"30"
},
{
"31"
,
"32"
,
"33"
},
{
"34"
,
"35"
,
"36"
},
...
@@ -23,7 +23,49 @@ public class reservation {
...
@@ -23,7 +23,49 @@ public class reservation {
switch
(
choice
=
input
.
nextInt
())
{
//switch case to run different outcomes
switch
(
choice
=
input
.
nextInt
())
{
//switch case to run different outcomes
case
1
:
//case if user chooses first class/1
case
1
:
//case if user chooses first class/1
System
.
out
.
println
(
"You have Chosen First Class"
);
//prints out the class that the user has chosen
System
.
out
.
println
(
"You have Chosen First Class"
);
//prints out the class that the user has chosen
break
;
boolean
seat
=
false
;
for
(
int
p
=
0
;
p
<
1
;
p
++)
{
for
(
int
q
=
0
;
q
<
3
;
q
++)
{
if
(
plane
[
p
][
q
]
!=
"XX"
)
{
seat
=
true
;
}
}
}
if
(
seat
==
true
)
{
while
(
true
)
{
System
.
out
.
println
(
"Would you like to choose a seat?(Y/N)"
);
String
choose
=
input
.
next
();
switch
(
choose
)
{
case
"N"
:
System
.
out
.
println
(
"Ok, You will be assigned the next available seat"
);
return
;
case
"Y"
:
System
.
out
.
println
(
"Ok please choose a seat:"
);
return
;
default
:
System
.
out
.
println
(
"invalid input please choose Y or N"
);
break
;
}
}
}
else
{
while
(
true
){
System
.
out
.
println
(
"There are no more seats, is it ok to be moved to another class?(Y/N)"
);
String
choose
=
input
.
next
();
switch
(
choose
)
{
case
"N"
:
System
.
out
.
println
(
"Sorry there is no available seat at the moment. The next flight is in 6 hours"
);
return
;
case
"Y"
:
System
.
out
.
println
(
"ok"
);
return
;
default
:
System
.
out
.
println
(
"invalid input please choose Y or N"
);
break
;
}
}
}
//return;
case
2
:
//case if user chooses business class/2
case
2
:
//case if user chooses business class/2
System
.
out
.
println
(
"You have Chosen Business Class"
);
//prints out the class that the user has chosen
System
.
out
.
println
(
"You have Chosen Business Class"
);
//prints out the class that the user has chosen
break
;
break
;
...
...
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