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
Which of the following is NOT a type of insurance fraud?
inessss [21]

Answer:

Arson

Explanation:

Because arson is setting something on fire on purpose to cause damage.

The others all are some form or another of insurance fraud.

8 0
2 years ago
Read 2 more answers
Which Of the following components leads to slow computer performance when it becomes outdated
Scorpion4ik [409]

guess its d drivers , since u said wen it gets outdated


8 0
3 years ago
Read 2 more answers
What is the output of the following C++ code?
SVETLANKA909090 [29]

Answer:

Your not including anything in your code.

Explanation:

According to your text all you have is #include. You didn't incldue any directives so you will get a error.

6 0
2 years ago
The key invention that enabled computers to go into every home and office is
Scrat [10]
<span><span />The Microprocessor is the key invention that enabled computers to go into every home and office. Microprocessor is a computer processor that enables the computer to run. It is also called as central processing unit. It is also a multipurpose and programmable device that accepts inputted data and process the data to provide an output. Microprocessor started from 8-bit design to 16bit, 32 bit, 64 bit and now it is produce a multi core design in the market. Faster and stronger design that can run heavier applications.</span>



8 0
3 years ago
Please help ASAP, will mark brainliest!
sp2606 [1]

Answer:

Stick to concrete nouns

Explanation:

The best technique to improve the web search result is that search with the help of keywords. These keywords help in searching the required results from search engines.

The keywords are actually nouns. Noun is name of object, place or person. So by using nouns we can search out required results.

For example

If we want to search about some persons bibliography, we use his name in our search. His name is an example of noun.

3 0
2 years ago
Other questions:
  • In the Word 2016 window, where is the Status bar located?
    11·2 answers
  • The cost of large ground based telescopes has remained the same since the 1800's costing the equivalent of about a billion dolla
    9·1 answer
  • A process that allows software-based networked computers to run multiple operating systems and programs and share storage is cal
    5·1 answer
  • It is safe to stand on the top step of a ladder provided it is braced property
    10·1 answer
  • If you turn on the Lock alpha button , what happens
    5·2 answers
  • An IT security threat is anything that might cause serious harm to a computer system, including someone stealing a laptop that c
    8·2 answers
  • Write in language C, please.
    8·1 answer
  • What is system software?
    14·1 answer
  • Identify the true statements about the approach to privacy around the world. a. Uncertainty concerning the nature, extent, and v
    11·1 answer
  • QUESTION 44 To determine whether a character entered is a letter of the alphabet, use the ________ function. isdigit fromkeyboar
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!