Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Java, write a program for a flight Itinerary. Flight Itinerary. For this proj

ID: 3680333 • Letter: I

Question

In Java, write a program for a flight Itinerary.

Flight Itinerary. For this project, you will create an array of airports.

You will ask the user how many legs this itinerary has and what is the Ground Speed , then the number of airports to ask will be one plus the number of legs. For example, if the user enters two legs, then you will ask the user information about Airport 1, Airport 2 and Airport 3. Then you will calculate the distance for each leg, that is the distance between Airport 1 and Airport 2 and the total flight time, then the distance between Airport 2 and airport 3, and it's total flight time. Finally, you will print out the itinerary with the distance and flight times, for example, if the user entered 2 legs at a speed of 300 mph (it's actually knots), you will ask for the information of the three airport, then display the itinerary like this:

Leg     From     To     Dist     Time (mins)

1         SAN       LAX 95       19

2         LAX        SFO 293     59

Total                           388     78

Explanation / Answer

import java.util.*;
class airports
{
   public static void main(String args[])
   {
       int legs, i;
       int speed;
       double km,totd=0,tott=0;
       String fm[]=new String[100];
       String t[]=new String[100];
       double dist[]=new double[100];
       double tim[]=new double[100];
       Scanner scan= new Scanner(System.in);

       System.out.println("Enter legs");
       legs=scan.nextInt();

       System.out.println("Enter speed");
       speed=scan.nextInt();
      
       km=speed/.62;

       for(i=0;i<legs;i++)
       {
           System.out.println("Enter Airport From");
           fm[i]=scan.nextLine();

           System.out.println("Enter Airport To");
           t[i]=scan.nextLine();

           System.out.println("Enter Distance");
           dist[i]=scan.nextDouble();

           tim[i]=dist[i]/km;

       }

                  
       for(i=0;i<legs;i++)
       {
           System.out.println((i+1)+" "+fm[i]+" "+t[i]+" "+dist[i]+" "+tim[i]+" ");
           totd=totd+dist[i];
           tott=tott+tim[i];
       }
       System.out.println("Total"+" "+totd+" "+tott);
   }
}

      

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote