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
The mathematical constant Pi is an irrational number with value approximately 3.1415928... The precise value of this constant ca
tatiyna

Answer:

I am writing a Python program:

def approxPIsquared(error):

   previous = 8

   new_sum =0

   num = 3

   while (True):

       new_sum = (previous + (8 / (num ** 2)))

       if (new_sum - previous <= error):

           return new_sum

       previous = new_sum

       num+=2    

print(approxPIsquared(0.0001))

Explanation:

I will explain the above function line by line.

def approxPIsquared(error):  

This is the function definition of approxPlsSquared() method that takes error as its parameter and approximates constant Pi to within error.

previous = 8     new_sum =0      num = 3

These are variables. According to this formula:

Pi^2 = 8+8/3^2+8/5^2+8/7^2+8/9^2+...

Value of previous is set to 8 as the first value in the above formula is 8. previous holds the value of the previous sum when the sum is taken term by term. Value of new_sum is initialized to 0 because this variable holds the new value of the sum term by term. num is set to 3 to set the number in the denominator. If you see the 2nd term in above formula 8/3^2, here num = 3. At every iteration this value is incremented by 2 to add 2 to the denominator number just as the above formula has 5, 7 and 9 in denominator.

while (True):  This while loop keeps repeating itself and calculates the sum of the series term by term, until the difference between the value of new_sum and the previous is less than error. (error value is specified as input).

new_sum = (previous + (8 / (num ** 2)))  This statement represents the above given formula. The result of the sum is stored in new_sum at every iteration. Here ** represents num to the power 2 or you can say square of value of num.

if (new_sum - previous <= error):  This if condition checks if the difference between the new and previous sum is less than error. If this condition evaluates to true then the value of new_sum is returned. Otherwise continue computing the, sum term by term.

return new_sum  returns the value of new_sum when above IF condition evaluates to true

previous = new_sum  This statement sets the computed value of new_sum to the previous.

For example if the value of error is 0.0001 and  previous= 8 and new_sum contains the sum of a new term i.e. the sum of 8+8/3^2 = 8.88888... Then IF condition checks if the

new_sum-previous <= error

8.888888 - 8 = 0.8888888

This statement does not evaluate to true because 0.8888888... is not less than or equal to 0.0001

So return new_sum statement will not execute.

previous = new_sum statement executes and now value of precious becomes 8.888888...

Next   num+=2  statement executes which adds 2 to the value of num. The value of num was 3 and now it becomes 3+2 = 5.

After this while loop execute again computing the sum of next term using       new_sum = (previous + (8 / (num ** 2)))  

new_sum = 8.888888.. + (8/(5**2)))

This process goes on until the difference between the new_sum and the previous is less than error.

screenshot of the program and its output is attached.

6 0
3 years ago
A small company is requesting a quote to refresh its wireless network. The company currently runs 60 autonomous APs and has plan
Annette [7]

Answer:

A small company is requesting a quote to refresh its wireless network. The company currently runs 60 autonomous APs and has plans to increase wireless density by 50% in the near future. The requirements state that the chosen solution should significantly decrease the management overhead of the current wireless network. The following should be recommended by the vendor in response to the quote request:

B. The use of autonomous APs with a wireless controller.

Explanation:

  • The option A  and D are not correct as the use of lightweight APs are not required here because they are already using autonomous APs which are fulfilling their needs.
  • The option B is correct as the use of autonomous APs with a wireless controller will allow them to decrease the management overhead as the wireless controller is used to manage the Access points in larger quantities.
  • The option C is incorrect as the load balancers are used to increase the capacity and reliability of applications as they distribute the traffic over number of servers so it is unable to decrease the management overhead.  
6 0
3 years ago
Question 10 of 10
ValentinkaMS [17]

Answer:

C. Dow Jones

Explanation:

It’s the Dow Jones certainly, and we also know it as Dow 30. You will find with a little research that Dow Jones is an index of the 30 carefully chosen blue-chip stocks, and general industrial stocks. And this is price prejudiced average, and of 30 stocks that can be well-thought-out as an all-purpose measure for the whole stock market performance.

3 0
2 years ago
If you know the unit prices of two different brands of an item you are better able to
vitfil [10]

Answer:

TO UNDERSTAND TO ITS VALUES AND ITS  FEATURES

Explanation:

4 0
3 years ago
Which words in the sentence make up the adjective phrase? Which word does the adjective phrase modify? The farmer delivers five
jasenka [17]
B....."........."........"...
6 0
3 years ago
Other questions:
  • The collection of all possible vulnerabilities that could provide unauthorized access to computer resources is called the:
    12·1 answer
  • A forensics workstation consisting of a laptop computer with almost as many bays and peripherals as a stationary workstation is
    10·1 answer
  • A customer comes into a computer parts and service store. The customer is looking for a device to help a person with accessibili
    5·1 answer
  • Name three recent advances that are influencing OS design.
    15·1 answer
  • What is not true of credit scores?
    11·1 answer
  • What is the best platform for a online meeting?
    10·2 answers
  • Subscribe to my you tube channel to get all your questions answered
    8·1 answer
  • After reading his e-mail messages, Orlando became very frustrated. Many of the messages he received did not conform to netiquett
    6·1 answer
  • Help pweeze this is due today :(<br><br> I will give u brainliest just pweeze, I need this answer :(
    8·1 answer
  • What is the meaning of s used in 0 and 1 in computer .​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!