package com.java;
import java.util.ArrayList;
import java.util.Scanner;
public class Menu {
static ArrayList<Flight> flight = new
ArrayList<Flight>();
static ArrayList<Ticketperson> ticket = new
ArrayList<Ticketperson>();
enum List {
z("Continue"), a("Add a new
flight"), b("Buy ticket"), c("Request a Check-In"), d("Process a
Check-In"),
e("Display Valid Check-Ins"),
f("Calculate Take-Off Load"), g("Exit");
private String option;
List(String option) {
this.option =
option;
}
public String getOption()
{
return
option;
}
}
public static void Takeoffload() {
Scanner input = new
Scanner(System.in);
int weight = 0;
int count = 0;
int allowedweight = 0;
System.out.println("Enter the
flight no:");
int Flightno =
input.nextInt();
for (Flight f : Menu.flight)
{
if
(f.getFlightno() == Flightno) {
allowedweight = f.getMaxLoad();
}
}
for (Ticketperson t : Menu.ticket)
{
if
(t.checkinflag) {
count++;
weight += t.getWeight();
}
}
weight = weight + 80 * count;
if (allowedweight > weight)
{
System.out.println("Plane can take off");
} else {
System.out.println("Plane can't take off");
}
}
public static void validcheckin() {
for (Ticketperson t : Menu.ticket)
{
if
(t.checkinflag) {
System.out.println("Check-In of " + t.getName()
+ " " + t.getSurname() + " Ticket No# "
+
t.getTicketno() + "n" + "From " +
Menu.flight.get(0).getOriginCity() + " to "
+
Menu.flight.get(0).getDestCity() + " Departure Time:" +
Menu.flight.get(0).getDay() + "/"
+
Menu.flight.get(0).getMonth() + "/" + Menu.flight.get(0).getYear()
+ " "
+
Menu.flight.get(0).getHour() + ":" + Menu.flight.get(0).getMinute()
+ "Check-In time: "
+
t.getDay() + "/" + t.getMonth() + "/" + t.getYear() + " " +
t.getHour() + ":" + t.getMinute()
+ "
Luggage Weight: " + t.getWeight());
}
}
}
public static void ProcessinReq() {
Scanner input = new
Scanner(System.in);
System.out.println("Enter your
ticket no:");
int ticketNo =
input.nextInt();
for (Ticketperson t : Menu.ticket)
{
if
(t.getTicketno() == ticketNo) {
if (t.getYear() == Menu.flight.get(0).getYear()
&& t.getMonth() == Menu.flight.get(0).getMonth()
&&
t.getDay() == Menu.flight.get(0).getDay()) {
//
System.out.println(Menu.flight.get(0).getHour() * 60 +
//
Menu.flight.get(0).getMinute());
//
System.out.println(t.getHour() * 60 + t.getMinute());
//
System.out.println((Menu.flight.get(0).getHour() * 60 +
//
Menu.flight.get(0).getMinute()) - t.getHour() * 60 + t.getMinute()
> 30);
if
((Menu.flight.get(0).getHour() * 60 +
Menu.flight.get(0).getMinute())
- (t.getHour() * 60 + t.getMinute()) > 30)
{
System.out.println("Check In Declined");
} else {
t.checkinflag = true;
}
}
}
}
}
public static void CheckinReq() {
Scanner input = new
Scanner(System.in);
System.out.println("Enter your
ticket no:");
int ticketNo =
input.nextInt();
for (Ticketperson t : Menu.ticket)
{
if
(t.getTicketno() == ticketNo) {
System.out.println("Enter the weight of
luggage");
t.setWeight(input.nextInt());
System.out.println("Enter your Check-In
Time:");
System.out.println("Year:");
t.setYear(input.nextInt());
System.out.println("Month:");
t.setMonth(input.nextInt());
System.out.println("Day:");
t.setDay(input.nextInt());
System.out.println("Hour:");
t.setHour(input.nextInt());
System.out.println("Minute");
t.setMinute(input.nextInt());
}
}
}
public static void BuyTicket() {
Scanner input = new
Scanner(System.in);
Ticketperson ticket = new
Ticketperson();
System.out.println("Enter the
flight no:");
int Flightno =
input.nextInt();
ticket.setFlightno(Flightno);
for (Flight f : Menu.flight)
{
if
(f.getFlightno() == Flightno) {
System.out.println("Enter your Passenger
Information;");
System.out.println("Your Name");
ticket.setName(input.next());
System.out.println("Your Surname");
ticket.setSurname(input.next());
System.out.println("Enter your seat no");
ticket.setSeatno(input.next());
System.out.println("Enter your class");
ticket.setClass1(input.next());
ticket.setTicketno(++f.ticketno);
System.out.println("Your Ticket no is :" +
ticket.getTicketno());
Menu.ticket.add(ticket);
} else
{
System.out.println("Invalid Flight.");
}
}
}
public static void newFlight() {
Scanner input = new
Scanner(System.in);
Flight flight = new Flight();
System.out.println("Enter the
flight no:");
flight.setFlightno(input.nextInt());
System.out.println("Enter the
Departure Time:");
System.out.println("Year:");
flight.setYear(input.nextInt());
System.out.println("Month:");
flight.setMonth(input.nextInt());
System.out.println("Day:");
flight.setDay(input.nextInt());
System.out.println("Hour:");
flight.setHour(input.nextInt());
System.out.println("Minute");
flight.setMinute(input.nextInt());
System.out.println("Enter the
Origin City:");
flight.setOriginCity(input.next());
System.out.println("Enter the
Destination City: ");
flight.setDestCity(input.next());
System.out.println("Enter the Max
Load: ");
flight.setMaxLoad(input.nextInt());
Menu.flight.add(flight);
}
public static void choice() {
System.out.println("(1)Add a new
flight.");
System.out.println("(2)Buy
ticket.");
System.out.println("(3)Request a
Check-In.");
System.out.println("(4)Process a
Check-In.");
System.out.println("(5)Display
Valid Check-Ins.");
System.out.println("(6)Calculate
Take-Off Load.");
System.out.println("(7)
Exit.");
System.out.println("Your
choice");
}
public static void main(String[] args) {
Scanner input = new
Scanner(System.in);
List choice = List.z;
while (choice != List.g) {
choice();
choice =
List.values()[Integer.parseInt(input.nextLine().trim())];
switch (choice)
{
case a:
newFlight();
break;
case b:
BuyTicket();
break;
case c:
CheckinReq();
break;
case d:
ProcessinReq();
break;
case e:
validcheckin();
break;
case f:
Takeoffload();
break;
default:
System.out.println("Out of range.");
}
}
}
}
class Flight {
int flightno;
int year;
int month;
int day;
int hour;
int minute;
String OriginCity;
String DestCity;
int maxLoad;
static int ticketno;
public int getFlightno() {
return flightno;
}
public void setFlightno(int flightno) {
this.flightno = flightno;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
public int getDay() {
return day;
}
public void setDay(int day) {
this.day = day;
}
public int getHour() {
return hour;
}
public void setHour(int hour) {
this.hour = hour;
}
public int getMinute() {
return minute;
}
public void setMinute(int minute) {
this.minute = minute;
}
public String getOriginCity() {
return OriginCity;
}
public void setOriginCity(String originCity)
{
OriginCity = originCity;
}
public String getDestCity() {
return DestCity;
}
public void setDestCity(String destCity) {
DestCity = destCity;
}
public int getMaxLoad() {
return maxLoad;
}
public void setMaxLoad(int maxLoad) {
this.maxLoad = maxLoad;
}
}
class Ticketperson {
int flightno;
int ticketno;
String name;
String surname;
String seatno;
String Class1;
int weight;
int year;
int month;
int day;
int hour;
int minute;
boolean checkinflag = false;
public int getFlightno() {
return flightno;
}
public void setFlightno(int flightno) {
this.flightno = flightno;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
public int getDay() {
return day;
}
public void setDay(int day) {
this.day = day;
}
public int getHour() {
return hour;
}
public void setHour(int hour) {
this.hour = hour;
}
public int getMinute() {
return minute;
}
public void setMinute(int minute) {
this.minute = minute;
}
public int getTicketno() {
return ticketno;
}
public void setTicketno(int ticketno) {
this.ticketno = ticketno;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getSeatno() {
return seatno;
}
public void setSeatno(String seatno) {
this.seatno = seatno;
}
public String getClass1() {
return Class1;
}
public void setClass1(String class1) {
Class1 = class1;
}
}
JAVA LANGUAGE int choice; Scanner in = new Scanner(System.in); while(true) { System.out.println(); System.out.println("(1) Add a new...
public static void main(String[] args) { int option=0; while(option<8){ Scanner input=new Scanner(System.in); System.out.println("Welcome! Please enter your name"); String name=input.next(); Person user= new Person(name); System.out.println("Your id: "+user.getID()); System.out.println("Login successful"); System.out.println("------------------------------"); while(option!=7){ System.out.println("1.Create and host a new meeting"); System.out.println("2.Cancel a meeting"); System.out.println("3.Attend an existing meeting"); System.out.println("4.Leave a meeting"); System.out.println("5.Display my meetings"); System.out.println("6.Display meetings organized by me"); System.out.println("7.Logout"); System.out.println("8.Exit the app"); option=input.nextInt(); switch(option){ case 1: break; case 2: break; case 3: break; case 4: break; case 5: break; case 6: break;...
NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...
NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...
IP requirements: Load an exam Take an exam Show exam results Quit Choice 1: No functionality change. Load the exam based upon the user's prompt for an exam file. Choice 2: The program should display a single question at a time and prompt the user for an answer. Based upon the answer, it should track the score based upon a successful answer. Once a user answers the question, it should also display the correct answer with an appropriate message (e.g.,...
Lab 7 Add three instance variables to your class RightTriangle from lab 5. The first two are of type int and are called xLoc and yLoc and the third is of type int called ID. Also add a static variable of type double called scaleFactor. This should be initialized to a default value of 1. Update the constructor to set the three new instance variables and add appropriate get and set methods for the four new variables. All set methods...
Programming Instructions:Using Java Object Oriented Principles, write a program which produces the code as indicated in the following specifications: Your program must be a console application that provides a user this exact menu:Please select one of the following:1: Add Client to Bank2: Display Clients in the Bank3: Set Bank Name4: Search for a Client5: Exit Enter your Selection: <keyboard input here> The menu must be displayed repeatedly until 5...
this needs to be done in Java using Using Multiple Generic Data Structures – LinkedList and ArrayList In this assignment, you will write a system to manage email address lists (ostensibly so that you could send emails to a list which has a name – which would send an email to each of the addresses in the list – although we will not actually implement sending emails. Displaying the list will simulate being able to send the emails). We will...
For Project 02 you’re going to take starter code I’m providing (See in BlackBoard under Projects->Project 02). The zip file contains a P02.java, a HelperClass.java, and an enumeration under Money.java. The only coding you’ll do will be in P02.java. I’ve already provided you with the menu and switch as well as all the methods you’ll need stubbed out. Your assignment is to take the program and complete it without adding any more methods but merely adding code to those stubbed...
I need the pseudocode and python for the four attached problems: 1. (Chapter 5 - For Loop) Logic Technical College has a current tuition of $10,000 per year. Tuition is scheduled to increase by 5% each year. Using a FOR loop, design a program that calculates and displays the tuition each year for the next ten years, like so: The tuition for year 1 will be: 10500.00 The tuition for year 2 will be: 11025.00 ……….. (You, of course will...