Answer:-
Code:-
import java.util.*;
class Flight{
static Scanner sc = new Scanner(System.in);
public static void displayArrays(String a[],double
p[],String s){
// displaying description in given
arrays
System.out.printf("\n%-13s%-15s%-10s\n","Number",s,"Prices");
System.out.println("==================================");
for(int
i=0;i<a.length;i++){
System.out.printf("%-13d%-15s%-10.2f\n",i+1,a[i],p[i]);
}
System.out.println();
}
public static int getNumber(){
//read input and return
return (sc.nextInt());
}
public static void displayitineraryArrays(String
d[],double p[]){
// displaying description in given
arrays,if list empty display empty message
if(d[0]==null){
System.out.println("\nYour itinerary list is empty");
}else{
System.out.printf("\n%-15s%-10s\n","Bookings","Prices");
System.out.println("------------------------");
for(int
i=0;i<d.length;i++){
System.out.printf("%-15s%-10.2f\n",d[i],p[i]);
}
System.out.println("------------------------");
double s
=getTotal(p) + (getTotal(p)*0.0825);
System.out.printf("%-15s%-10.2f\n","Total + tax",s);
System.out.println();
}
}
public static double getTotal(double p[]){
double s = 0;
for(int
i=0;i<p.length;i++)
s += p[i];
return s;
}
public static void clearBookings(String a[]){
for(int
i=0;i<a.length;i++)
a[i] =
null;
}
public static void clearPrices(double a[]){
for(int
i=0;i<a.length;i++)
a[i] = 0;
}
public static void main(String[] args) {
String flights[] =
{"Morning","Afternoon","Evening"};
double flightPrices[] =
{500.00,600.00,700.00};
String hotelStays[] = {"One
night","Two nights","Three nights"};
double hotelStaysPrices[] =
{100.00,240.00,390.00};
int n;
String bookings[] = new
String[2];
double prices[] = new
double[2];
do{
//Menu
System.out.println("\n Welcome to Mustang Tours");
System.out.println("1) Browse Flights and add booking to
itinerary");
System.out.println("2) Browse Hotel Stays and add booking to
itinerary");
System.out.println("3) View itinerary");
System.out.println("4) Display total and pay");
System.out.println("5) Cancel bookings");
System.out.println("9) Exit");
System.out.print("Enter option: "); //Ask user to enter
option
n =
sc.nextInt();
switch (n)
{
case 1:
displayArrays(flights,flightPrices,"Flights");
System.out.print("Enter
option(-1 to go to menu): ");
int i = getNumber();
if(i!=-1){
bookings[0] = flights[i-1];
bookings[1] = hotelStays[i-1];
prices[0]
= flightPrices[i-1];
prices[1]
= hotelStaysPrices[i-1];
}
break;
case 2:
displayArrays(hotelStays,hotelStaysPrices,"Hotel Stays");
System.out.print("Enter
option(-1 to go to menu): ");
int j = getNumber();
if(j!=-1){
bookings[0] = flights[j-1];
bookings[1] = hotelStays[j-1];
prices[0]
= flightPrices[j-1];
prices[1]
= hotelStaysPrices[j-1];
}
break;
case 3:
displayitineraryArrays(bookings,prices);
break;
case 4:
System.out.println(getTotal(prices));
break;
case 5:
clearBookings(bookings);
clearPrices(prices);
break;
case 9:
System.out.println("Thank
You...");
break;
default:
System.out.println("Please
enter valid option");
}
}while(n!=9);
}
}
Output:-
In this lab, you will create a program to help travelers book flights and hotel stays that will b...
C++ Question Question 3 [43] The Question: You are required to write a program for an Online Tutoring Centre to determine the weekly rate depending on the number of sessions the students attend and then to calculate total revenue for the center. The Online Tutoring Centre charges varying weekly rates depending on the on grade of the student and number of sessions per week the student attends as shown in Table 1 below. Grade 8 9 Session 1 75 80...
making a file You are tasked with creating a text-based program for storing data on Hotel Room Bookings - however, as this is a comparative languages course, you will be creating the same application in the following three programming languages: • Java, • Python, and • Lisp As you implement the application in each language you should keep notes on: - The features of the languages used, - Which features you found useful, and - Any issues or complications which...
This project will allow you to practice with one dimensional arrays, function and the same time review the old material. You must submit it on Blackboard and also demonstrate a run to your instructor. General Description: The National Basketball Association (NBA) needs a program to calculate the wins-losses percentages of the teams. Write a complete C++ program including comments to do the following: Create the following: •a string array that holds the names of the teams •an integer array that...
Hi I need help with a java program that I need to create a Airline Reservation System I already finish it but it doesnt work can someone please help me I would be delighted it doesnt show the available seats when running the program and I need it to run until someone says no for booking a seat and if they want to cancel a seat it should ask the user to cancel a seat or continue booking also it...
Your assignment is to write a grade book for a teacher. The teacher has a text file, which includes student's names, and students test grades. There are four test scores for each student. Here is an example of such a file: Count: 5 Sally 78.0 84.0 79.0 86.0 Rachel 68.0 76.0 87.0 76.0 Melba 87.0 78.0 98.0 88.0 Grace 76.0 67.0 89.0 0.0 Lisa 68.0 76.0 65.0 87.0 The first line of the file will indicate the number of students...
In this lab, you will create one class named ArrayFun.java which will contain a main method and 4 static methods that will be called from the main method. The process for your main method will be as follows: Declare and create a Scanner object to read from the keyboard Declare and create an array that will hold up to 100 integers Declare a variable to keep track of the number of integers currently in the array Call the fillArray method...
public static double[] getVolumes(double[] base, double[] height, double[] length) Write a Java program called TriangularPrisms which does the following: In the main method: Use a for loop which repeats three times. Within the loop, a. prompt the user to enter the base of the triangular prism and store the value in a double array called base b. prompt the user to enter the corresponding height and store the value in a double array called height c. prompt the user to...
C++ Create an array-based implementation of a stack. Each element of the stack should store a string. The stack class should include 3 private member variables (maximum stack size, top of the stack index, and a pointer to the array that holds the stack elements). Public member methods should include a constructor (with an argument of stack maximum size that is used to create a dynamic array), a destructor (that deletes the dynamic array), a push method (argument is a...
Using Java In this assignment we are working with arrays. You have to ask the user to enter the size of the integer array to be declared and then initialize this array randomly. Then use a menu to select from the following Modify the elements of the array. At any point in the program, if you select this option you are modifying the elements of the array randomly. Print the items in the array, one to a line with their...
Java Programing Code only Ragged Array Assignment Outcome: Student will demonstrate the ability to create and use a 2D array Student will demonstrate the ability to create and use a jagged array Student will demonstrate the ability to design a menu system Student will demonstrate the ability to think Program Specifications: Write a program that does the following: Uses a menu system Creates an array with less than 25 rows and greater than 5 rows and an unknown number of...