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
If I wanted to repeat an action such as a heading for a paper, it would be helpful to _____. create a citation create a caption
salantis [7]
Um... Copy and paste
7 0
3 years ago
Read 2 more answers
How does beamforming improve network service?
fenix001 [56]

Beamforming can improve network service by using device locations to better target service signals.

This is because, beamforming helps to deliver higher signal quality to the target receiver.

<h3>What is beamforming?</h3>

beamforming can be regarded as application of different radiating elements that is transmitting the same signal.

This signal is usually identical in wavelength and phase, and  by reinforcing the waves in a specific direction the goal can be acheived.

Learn more about beamforming at:

brainly.com/question/12809344

7 0
2 years ago
Which of the following is a trademark automatically received by an organization when a symbol is being consistently used in the
Mashcka [7]

Complete Question:

Which of the following is a trademark automatically received by an organization when a symbol is being consistently used in the normal course of business?

Group of answer choices

A. Open source trademark.

B. Common law trademark.

C. Registered trademark.

D. Open source trademark.

Answer:

B. Common law trademark.

Explanation:

A common law trademark can be defined as a protection or enforceable mark for a product name, logo, symbol or brand name used to distinguish goods and services prior to its registration with the state or federal government. Common law trademark is a trademark which is automatically received by an organization when a symbol is being consistently used in the normal course of business.

This ultimately implies that, common law trademarks are not governed by any statute and as such are only limited to the geographical location where they are used.

For instance, if a tomato paste is being sold to consumers with the product name "Ginoo" in Florida, the company's trademark applies to Florida only. Thus, another company can use the product name without any trademark infringement in other states of the country such as New York, Washington DC, California etc. except in Florida due to a common law trademark.

4 0
3 years ago
A small amount of memory stored on the central processor for easy access is called
expeople1 [14]

The answer is : Cache.  It is a small amount of memory stored on the central processor for easy access.  Cache is where active data are placed for easier access, it stores recently used information so that it can be quickly accessed at a later time. Some types of cache are browser cache, disk cache, memory cache, and processor cache.

3 0
2 years ago
Read 2 more answers
What is the index of 7 in this list?<br> [5, 6, 10, 7, 3, 2.51]
kotykmax [81]
5 or 7 I believe Good luck!
6 0
2 years ago
Read 2 more answers
Other questions:
  • You are required to design a 4-bit even up-counter using D flip flop by converting combinational circuit to sequential circuit.
    15·1 answer
  • print out the last even number from an array of integers, if there is no even number, then print out a sentence indicating so.
    5·1 answer
  • Write a program that reads in ten numbers and displays the number of distinct numbers and the distinct numbers separated by exac
    7·1 answer
  • True or False: Changing a bid package's status to "Closed" removed it from the bidder's Planroom and the bidder will no longer b
    15·1 answer
  • Write a program that first reads in the name of an input file, followed by two strings representing the lower and upper bounds o
    8·1 answer
  • What attracts attention and adds spatial depth to a two-dimensional design.
    9·1 answer
  • You are given a 5-letter word (for example, abcde). Write a C-Program which outputs all possible unique 5 letter permutations of
    13·1 answer
  • This isn't really a question ,but a random fact about Fnaf William Aton
    7·2 answers
  • True or False? Security code is almost always open source!<br> True<br> False
    8·2 answers
  • What is bigger that terbites
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!