Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 DebugCircle class compiles without error, the DebugCircle class methods work without error, the DebugFour1 class compiles without error and the DebugFour1 program accepts user input and displays the correct output.

An example of the program is shown below:

Enter a radius for a circle >> 7 The radius is 7 The diameter is 14 The area is 153.93791

FIRST CODE:

public class DebugCircle

{

private int radius;

private int diameter;

private final double PI = 3.14159;

private double area;

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

public DebugCircle(int r)

{

radius = r;

diameter = 2 * r;

area = PI * r * r;

}

public int getRadius();

{

return radiuss;

}

public void getDiameter()

{

return diameter;

}

public double getArea()

{

return area;

}}

SECOND CODE:

// This class uses a DebugCircle class

// to instantiate a Circle object

import java.util.Scanner;

public class DebugFour1

{

public static void main(String args[])

{

Scanner input = new Scanner(System.in);

int radius;

DebugCircle c = new Circle();

System.out.print("Enter a radius for a circle >> ");

radius = input.nextInt();

c = new DebugCircle(c);

System.out.println("The radius is " + c.getRad());

System.out.println("The diamter is " + c.getDiam());

System.out.println("The area is " + c.getArea());

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

Describe the even planning process and explain why it is helpful.

Answered: 1 week ago

Question

Differentiate the function. r(z) = 2-8 - 21/2 r'(z) =

Answered: 1 week ago