Question: JAVA CODING The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem,

JAVA CODING

The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly Make sure the DebugTrip class compiles without error, the DebugTrip class methods work without error, the DebugFour4 class compiles without error and the DebugFour4 program accepts user input and displays the correct output.

An example of the program is shown below:

Enter destination city >> Warsaw Enter departure city >> Oslo Enter mode of transportation >> Airplane Going to Warsaw Leaving from Atlanta Going by car Going to Warsaw Leaving from Oslo Going by car Going to Warsaw Leaving from Oslo Going by Airplane

FIRST CODE:

public class DebugTrip

{

private String destination;

private String departure;

private String mode;

private static final String DEFAULT_CITY = "Atlanta";

private static final String DEFAULT_MODE = "car";

public DebugTrip() {}; // Do not remove this line

public DebugTrip(String destination)

{

this(destination, DEFAULT_CITY, DEFAULT_MODE);

}

public DebugTrip(String destination, String departure)

{

this(destination);

this(departure);

}

public DebugTrip(String destination, String departure, String mode)

{

this.destination = destination;

this.departure = departure;

this.mode = mode;

}

public String getDestination()

{

return destination;

}

public String getDepartureCity()

{

return departure;

}

public String getMode()

{

return mode;

}

}

SECOND CODE:

import java.util.Scanner;

public class DebugFour4

{

public static void main(String args[])

{

Scanner input = new Scanner(System.in);

String destinationCity;

String departureCity;

String mode;

DebugTrip trip1;

DebugTrip trip2;

DebugTrip trip2;

System.out.print("Enter destination city >> ");

destinationCity = input.nextLine();

System.out.print("Enter departure city >> ");

departureCity = input.nextLine();

System.out.print("Enter mode of transportation >> ");

mode = input.nextLine();

trip1 = new DebugTrip(destinationCity);

trip2 = new DebugTrip(destinationCity, departureCity);

trip3 = new DebugTrip(destinationCity, departureCity, mode);

display(trip1);

display(trip2);

display(trip3);

}

public static void display(DebugTrip trip)

{

System.out.println("Going to " + trip.getDestination());

System.out.println(" Leaving from " + trp.getDepartureCity());

System.out.println(" Going by " + trip.getMode());

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!