Question: Instructions The files provided in the code editor contain syntax and / or logic errors. In each case, determine and fix the problem, remove all
Instructions
The files provided in the code editor contain syntax andor 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.
An example of the program is shown below:
Do you want to add a rowboat or ocean liner Do you want to add a rowboat or ocean liner Do you want to add a rowboat or ocean liner This ocean linerboat carries and is powered by four engines This rowboat carries and is powered by oars This ocean linerboat carries and is powered by four engines
Task : The DebugCustomer class compiles without error.
Task : The DebugRowboat class compiles without error.
Task : The DebugOceanLiner class compiles without error.
Task : The DebugNine class compiles without error.
Task : The DebugNine program accepts user input and displays the correct output.
Declares an array that holds different boat types
import java.util.Scanner;
public class DebugNine
public static void mainString args
DebugBoat ref new DebugBoat;
Scanner input new ScannerSystemin;
int x;
int option;
DebugRowboat rowboat;
DebugOceanLiner liner;
forx ; x ref.length; x
System.out.printlnDo you want to add a rowboat or;
System.out.print ocean liner ;
option input.nextInt;
ifoption
rowboat new FixDebugRowboat;
ref rowboat;
else
liner new FixDebugOceanLiner;
refx liner;
forx ; x ref.length; x
refxsetPassengers;
refxsetPower;
System.out.printlnrefxtooString;
public abstract class DebugBoat
String boatType new String;
int passengers;
String power new String;
public DebugBoatString bt
boatType bt;
public boolean equalsDebugBoat otherBoat
boolean result;
ifpassengers other.passengers &&
powerequallsotherBoatpower
result true;
else
result false;
return result;
public String toString
returnThis boatType boat carries passengers
and is powered by power;
public abstract void setPower;
public abstract void setPassengers;
public class DebugOceanLiner extends DebugBoat
public DebugOceanLiner
superocean liner";
setPassengers;
setPower;
public void setPassengers
passengers ;
public void setPower
superpower "four engines";
public class DebugRowboat extends DebugBoat
public FixDebugRowboat
superrow;
setPassengers;
setPower;
public void setPassengers
super.passngers ;
public void setPower
super.power "oars";
Please help debug these using java
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
