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

The following code contains many errors. The errors may be syntax, logic, or vio

ID: 3586943 • Letter: T

Question

The following code contains many errors. The errors may be syntax, logic, or violations of conventions discussed in class. Copy this code into DrJava and make any necessary corrections to the code so that it compiles and produces the required output when run. Also, make sure that all naming conventions are followed.

// Calculates the area & circumference of a circle & return the area value

Public class CircleStats {

   

  public static void main(String[] args) {

          Scanner console = new Scanner();

          int area = stats(console);

  }

  // This method prints the

   public static String Stats(Scanner console) {

          system.out.print("Enter the diameter of a circle: )

          int diameter = console.nextDouble;

          double radius = diameter/2;

          System.out.println("For a circle with Radius =" + Radius);

          System.out.println(" The circumference is: " + PI * diameter);

          System.out.println(" and the area is: " + PI * radius ^ 2;

   };

}

Explanation / Answer

Answer:

I have corrected the code and given a right code.

class circle

{

double radius;

void setData(double r)

{

radius=r;

}

void area()

{

double circleArea=Math.PI*radius*radius;

System.out.println("area of circle is:"+circleArea);

}

void circumference()

{

double cir=2*Math.PI*radius;

System.out.println("circumference of circle is:"+cir);

}

}

public class AreaAndCircumference

{

public static void main(String[] args)

{

circle obj=new circle();

obj.setData(3.5);

obj.area();

obj.circumference();

}

}

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