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
Reika [66]
3 years ago
8

The calcCircleCircumf() method invoked within in the CircleStatsTester class is overloaded. Write the overloaded methods in the

incomplete public CircleStats class.
public class CircleStats
{
public CircleStats()
{
}

//…code goes here — use the Math constant for pi rather than 3.14
}

public class CircleStatsTester
{
public static void main(String[] args)
{

int diameter = 5;
double radius = 2.5;
CircleStats cStats = new CircleStats();

System.out.println("The circumference = " + cStats.calcCircleCircumf(diameter));
System.out.println("The circumference = " + cStats.calcCircleCircumf(radius));

}
}
Computers and Technology
1 answer:
solong [7]3 years ago
7 0

Answer:

The program to this question as follows:

Program:

class CircleStats //defining class  

{

CircleStats() //creating default constructor

{

}

float calcCircleCircumf(float radius) //defining method  

{

   return (float)(2 * Math.PI * radius); //return value

}

double calcCircleCircumf(double diameter) //overload the method

{

   return (2 * Math.PI * (diameter/2)); //return value

}

}

public class CircleStatsTester //defining class  

{

public static void main(String ar[]) //defining main method  

{

int diameter = 5; //defining integer variable

double radius = 2.5;//defining float variable

CircleStats cStats = new CircleStats(); //creating CircleStats class object

System.out.println("The circumference = " + cStats.calcCircleCircumf(diameter)); //print value

System.out.println("The circumference = " + cStats.calcCircleCircumf(radius));  //print value

}

}

Output:

The circumference = 31.4

The circumference = 7.853981633974483

Explanation:

In the above java program code, two-class is declared that are "CircleStats and CircleStatsTester". In the class "CircleStats" a default constructor is created then method overloading is performed in which two method is defined that have the same name but different parameters.

  • In the first-time method declaration, it contains a float variable "radius" in its parameter to calculate and return its value.
  • In the second time method declaration, it contains a double variable "diameter" in its parameter, calculates and returns its value.

Then another class CircleStatsTester is defined inside this class the main method is defined. In the main method, an integer and double type variable is defined that contains a value that is "diameter = 5 and radius = 2.5". In this method, an above class CircleStats object is created and call this class functions.

You might be interested in
To meet the requirement for the number of vdss on board, what must be true about pyrotechnic vdss?
asambeis [7]

Answer: They must be dated.

Explanation: If pyrotechnic VDSs are used, they must be dated. Expired VDSs may be carried on board, but a minimum of three unexpired VDSs must be carried in the vessel.

5 0
2 years ago
In order to allow communication between vlans for exchange of data what must be used?​
lana66690 [7]
<span>In order to allow communication between vlans for exchange of data what must be used?

Router must be used</span>
4 0
3 years ago
Which of the following things would you access from the Program &amp; Courses page? Course descriptions Tutorial videos Account
Paraphin [41]

Course descriptions.

5 0
3 years ago
The letters a, e, i, o and u are the only vowels. Write a function named vowelUseDict() takes a string t as a parameter and comp
Andru [333]

Please specify the programming language.


3 0
3 years ago
what's the best mouse for fast clicking ? I play a lot of fps and a lot of pvp games I need a mouse that I can click fast with a
kondaur [170]
Alenware hp dell logtech, and i know others
7 0
3 years ago
Other questions:
  • Yet another variation: A better packet switched network employs the concept of acknowledgment. When the end user’s device receiv
    11·1 answer
  • Define and test a function myRange. This function should behave like Python’s standard range function, with the required and opt
    11·2 answers
  • PLEASE HELP!!!!
    7·1 answer
  • Dillard’s wants to learn about its consumers' attitudes toward online purchases. There are numerous studies that are available a
    9·1 answer
  • What output is generated by this for loop?
    6·1 answer
  • CLS <br> N = 1<br> FOR J = 1 TO 5 <br> PRINT N<br> N = 10*N+1 <br> NEXT J<br> END
    14·1 answer
  • Can someone help me?
    10·1 answer
  • In the last two decades, how have cameras evolved?
    12·2 answers
  • WILL GIVE BRAINLIEST!!!!!!!
    10·2 answers
  • Suppose that you have the following definitions:
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!