The Circle and CircleTester have been created, but they have errors. The public and private settings for variables and methods are 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())
}
}

Answers

Answer 1

Answer:

CIRCLE.JAVA

public class Circle {

  private double radius;

  public Circle(double myRadius) {

    radius = myRadius;

    private void setRadius(int myRadius){

    radius = myRadius;

 }

 public double getDiameter() {

    return radius*2;

 }

 public double getRadius() {

   return radius;

 }

 public double getPerimeter() {

   return Math.PI*getDiameter();

 }

 public 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())

 }

}

Explanation:

public class Circle {

  //This could be made private or public.

  //Making it private is better

  private 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

  public 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)

 public 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)

 public 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)

 public 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())

 }

}


Related Questions

1.16 LAB: Input and formatted output: House real estate summary Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two inputs, current price and last month's price (both integers). Then, output a summary listing the price, the change since last month, and the estimated monthly mortgage computed as (currentPrice * 0.051) / 12 (Note: Output directly. Do not store in a variable.).
Ex: If the input is:
200000 210000
the output is:
This house is $200000. The change is $-10000 since last month.
The estimated monthly mortgage is $850.0.
Note: Getting the precise spacing, punctuation, and newlines exactly right is a key point of this assignment. Such precision is an important part of programming.
import java.util.Scanner;
public class LabProgram {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int currentPrice;
int lastMonthsPrice;
currentPrice = scnr.nextInt();
lastMonthsPrice = scnr.nextInt();
/* Type your code here. */
}

Answers

Answer:

Please find the complete code and the output in the attachement.

Explanation:

In the code, a class "LabProgram" is defined, and inside the main method two integer variable "currentPrice and lastMonthsPrice" is defined that uses the scanner class object is used for a user input value, and in the next step, two print method is declared that print the calculate of the integer variable.

The program is an illustration of output formats in Java

The statements that complete the program are:

System.out.printf("This house is $%d. The change is $%d since last month.\n",currentPrice,(currentPrice - lastMonthsPrice));System.out.printf("The estimated monthly mortgage is $%.1f.\n",(currentPrice * 0.051)/12);

To format outputs in Java programming language, we make use of the printf statement, followed by the string literal that formats the required output

Take for instance:

To output a float value to 2 decimal place, we make use of the literal "%.2f"

Read more about Java programs at:

https://brainly.com/question/25458754

what time is spellrd the same forwards and backwards​

Answers

12:21 is the correct answer

A specification can be a written document, a set of graphical, a formal mathematical model, a collection of usage scenarios (or, use cases), a prototype, or any combination of these.
A. True
B. False

Answers

Answer:

The given statement is "True". A further explanation is given below.

Explanation:

The specification would be a necessary condition that is explicitly indicated, for obvious reasons, concerning the great components throughout the prototype of being something. A detailed explanation of that same performance aspects, normally with particular established standards, is presented in terms appropriate to lead to the creation both for real manufacturing and building methods of such a component with either the personality traits mentioned throughout the structural performance.

So the above is the appropriate response.

Assuming dataFile is an ofstream object associated with a disk file named payroll.dat, which of the following statements would write the value of the salary variable to the file
A) cout < B) ofstream C) dataFile << salary;
D) payroll.dat <

Answers

Answer:

dataFile << salary;

Explanation:

To write salary to a file (payroll.dat) using ofstream, you make use of the following instruction:

ofstream dataFile;

myfile.open ("payroll.dat");

myfile <<salary;

myfile.close();

This line creates an instance of ofstream

ofstream dataFile;

This line opens the file payroll.dat

myfile.open ("payroll.dat");

This is where the exact instruction in the question is done. This writes the value of salary to payroll.dat

myfile <<salary;

This closes the opened file

myfile.close();

Other Questions
why does tilly pull over when chasing goldfinger?A. Her car engine stopsB. She is mad a BondC. Bond slashes her tireD. She thinks Bond is interfering A political action committee wanted to estimate the proportion of county residents who support a change to the county leash law. They took a random sample of 600 county residents and found that the proportion who wanted to change the law was 33% with a margin of error of +/- 4% (with 95% confidence). This implies:_____a. If we took another sample of 600 residents the sample proportion would definitely be between 29% and 37%.b. If we take many other samples from this population 95% of them will have a sample proportion that is between 29% and 37%.c. We can not conclude anything about the population parameter since this is only a sample.d. We are 95% confident that the true proportion of county residents who want the law changed is between 29% and 37%.e. There is a 95% chance that the true parameter is 33%. I need help its urgent please I would really appreciate it 1.) Determine if the coordinate points represent a function. (1.3). (2.6). (3.9). (4. 12). (5.15 O Function O Not a FunctionO both Why my video ads are not working ? Please write 2 PARAGRAPHS about your brain on music. Someone tell me the answer A dolphin travels a distance 20 miles up the coastline in 153 minutes.If 1 mile is equal to 1609 meters,then what is the dolphins average speed in meters/seconds rounded to the nearest tenth? Please help mewhat is the premiter of the semi circle 1.What common characteristics do you notice in all the marine ecosystems? What are some major differences? A telemarketer earns a fixed amount for each call that he makes, as shown inthe graph below.If the telemarketer makes 12 calls, how much will he earn in total?A. $4.80B. $9.60C. $0.80D. $1.20 what is the square root of 5 divided by 5 square root of 3? Copy the proof on paper, mark the givens in the diagram, and fill in the blanks to complete the proof. what three things might influence a slide when conditions are right? Smith Company had the following on the dates indicated: 12/31/16 12/31/16 Total Assests $60,000 $330,000Total Liabilities 35,000 25,000Smith had no stock transactions in 2016; thus, the change in stockholders' equity for 2016 was due to net income and dividends. If dividends were $70,000, how much was Smith's net income for 2016? Use the accounting equation and the statement of retained earnings. a. $220,000b. $290,000c. $150,000d. $360,000 why do an increasing number of Americans, the same people who admire the slender look so often featured in the media, exercise too little and eat too much? what is this fromif you judge a FISH for its ability to climb a TREE it will-......... What is ATP? How does it provide energy Problem: 2 - $(7 2y) = -3Step 1: -3(7 2y) = -3Step 2: -21 + 6y=-3Step 3: by = 18Step 4: y = 3Determine which number step the mistake is Made and describe the error 3x-6=7x-3 3. 6please help!!!!!!!