1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
LiRa [457]
2 years ago
8

The Circle and CircleTester have been created, but they have errors. The public and private settings for variables and methods a

re not all correct.
Your job is to go through and fix them. You will need to make edits in both files to get them working correctly, but once complete, your output should match the output below.
Sample Output:
Circle with a radius of 5.0
The diameter is 10.0
The perimeter is 31.41592653589793
CIRCLE.JAVA
public class Circle {
public double radius;
private Circle(double myRadius) {
radius = myRadius;
private void setRadius(int myRadius){
radius = myRadius;
}
private double getDiameter() {
return radius*2;
}
public double getRadius() {
return radius;
}
private double getPerimeter() {
return Math.PI*getDiameter();
}
private String toString() {
return "Circle with a radius of " + radius;
}
}
CIRCLE TESTER.JAVA
public class CircleTester {
public static void main(String[] args) {
Circle circ = new Circle(10);
circ.radius = 5;
System.out.println(circ);
System.out.println("The diameter is " + circ.getDiameter());
System.out.println("The perimeter is " + circ.getPerimeter())
}
}
Computers and Technology
1 answer:
professor190 [17]2 years ago
8 0

<u>Answer:</u>

CIRCLE.JAVA

public class Circle {

  <em>private</em><em> </em>double radius;

  <em>public</em> Circle(double myRadius) {

    radius = myRadius;

    private void setRadius(int myRadius){

    radius = myRadius;

 }

 <em>public </em>double getDiameter() {

    return radius*2;

 }

 public double getRadius() {

   return radius;

 }

 <em>public </em> double getPerimeter() {

   return Math.PI*getDiameter();

 }

 <em>public</em> String toString() {

    return "Circle with a radius of " + radius;

 }

}

CIRCLE TESTER.JAVA

public class CircleTester {

 public static void main(String[] args) {

    Circle circ = new Circle(10);

    circ.radius = 5;

    System.out.println(circ);

    System.out.println("The diameter is " + circ.getDiameter());

    System.out.println("The perimeter is " + circ.getPerimeter())

 }

}

<u>Explanation:</u>

public class Circle {

  //This could be made private or public.

  //Making it private is better

  <em>private</em><em> </em>double radius;

  //This is a constructor. It should be made public

  //since it would most likely be used in another class

  //to create an object of this class.

  //Making it private means no other external class can create

  //an object of this class.

  //Since the tester class (CIRCLETESTER.java), as shown on line 3,

  // needs to create

  //an object of this class, this should be made public

  <em>public</em> Circle(double myRadius) {

    radius = myRadius;

    private void setRadius(int myRadius){

    radius = myRadius;

 }

 //This should be made public since it will be

// used in another class (CIRCLETESTER.java in this case)

 <em>public </em>double getDiameter() {

    return radius*2;

 }

 public double getRadius() {

   return radius;

 }

 //This should be made public since it will be

 //used in another class (CIRCLETESTER.java)

 <em>public </em> double getPerimeter() {

   return Math.PI*getDiameter();

 }

 //The toString() method is the string representation

 //of an object and is called when there is an attempt to

 //print the object. It should be made public since it will

 //be used in another class (CIRCLETESTER.java)

 <em>public</em> String toString() {

    return "Circle with a radius of " + radius;

 }

}

CIRCLE TESTER.JAVA

public class CircleTester {

 public static void main(String[] args) {

    Circle circ = new Circle(10);

    circ.radius = 5;

    System.out.println(circ);

    System.out.println("The diameter is " + circ.getDiameter());

    System.out.println("The perimeter is " + circ.getPerimeter())

 }

}

You might be interested in
The term ____ refers to a wide variety of different database technologies that were developed in order to overcome some of the l
ella [17]
Database management systems are used to store and to access information.
In <span>the Relational Database Management System </span>(RDBMS), all the data is in the form of simple columns and rows in a table. Structured Query Language (SQL) is is the standard query language for RDBMS. Some of the disadvantages of RDBMS are: not enough storage area to handle data such as images, digital and audio/video, do not provide good support for nested structures,not much efficient and effective integrated support.
<span>The term object oriented database management systems (OODBMS)  refers to a wide variety of different database technologies that were developed in order to overcome some of the limitations of relational databases.</span>





5 0
3 years ago
A distinguishing feature of methods that have the reserved word void in the method header is that they have:.
aliina [53]

Answer:

no return statements

Explanation:

3 0
2 years ago
Musical instruments cause the air to vibrate, sending waves that are detected by our senses. The energy from these vibrations of
Assoli18 [71]
B. Sound.

Explanation - instruments create sound waves
4 0
3 years ago
When an object is falling because of gravity, the following formulacan be used to determine the distance the object falls in asp
ser-zykov [4K]

Answer:

True

Explanation:

When an object is falling under the influence of gravity, the distance of fall as a function of time is given by:

D(t)=ut + 1/2 * a * t^2

Where

u = initial velocity of the object ( = 0 in this case as the object is falling only under gravity),

a = acceleration of the falling object = g = 9.8 m/s^2 which represents the acceleration due to gravity.

Simplifying,

D(t) = 1/2 * g * t^2

6 0
3 years ago
Which term represents a computational instruction stored in computer memory? A. operator B. opcode C. operand D. command
STALIN [3.7K]

Answer:

B - Opcode

Explanation:

A computational instruction with operands is a command so computational instructions is just an opcode.

5 0
2 years ago
Read 2 more answers
Other questions:
  • Consider the following code example:
    9·1 answer
  • ____ deals with ensuring that data is protected against unauthorized access, and if the data are accessed by an authorized user,
    10·1 answer
  • In addition to compiling the list of user access requirements, applications, and systems, the BIA also includes processes that a
    5·1 answer
  • Which is a way that computer simulations of medicines could help reduce ethical issues in drug research? computer simulations co
    5·1 answer
  • What term refers to mathematical equations used in Excel to perform calculations?
    8·1 answer
  • Which of the following is true of how computers represent numbers?
    9·2 answers
  • How to change color of object in photoshop?
    10·2 answers
  • The term ________ refers to the use of a single unifying device that handles media, Internet, entertainment, and phone needs. Gr
    8·1 answer
  • The purpose of Appetizers on the menu​
    6·2 answers
  • QUICK HELP ME PLEASE
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!