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
olga55 [171]
2 years ago
14

Imagine that you have access to a class named MyCircle that has void setRadius(double r) and double getRadius() methods. Write a

static method that accepts a MyCircle array. The method should accomplish two goals: it should return the average of the radius’s for all MyCircles that have a positive radius, and for any MyCircles that have a negative radius it should set the radius to 0.
Computers and Technology
1 answer:
Nikitich [7]2 years ago
7 0

Code for the method described in the question in java:

public static double averageRadius(MyCircle[] myCircles) {

       double sum = 0;

       for (MyCircle myCircle: myCircles) {

           if(myCircle.getRadius() < 0) myCircle.setRadius(0);

           sum += myCircle.getRadius();

       }

       return sum / myCircles.length;

   }

And the complete program:

import java.util.Random;

public class MyCircle {

   private double radius;

   public double getRadius() {

       return radius;

   }

   public void setRadius(double radius) {

       this.radius = radius;

   }

   public static double averageRadius(MyCircle[] myCircles) {

       double sum = 0;

       for (MyCircle myCircle: myCircles) {

           if(myCircle.getRadius() < 0) myCircle.setRadius(0);

           sum += myCircle.getRadius();

       }

       return sum / myCircles.length;

   }

   public static void main(String[] args) {

       Random random = new Random();

       int N = 10;

       MyCircle[] myCircles = new MyCircle[N];

       for (int i = 0; i < myCircles.length; i++) {

           myCircles[i] = new MyCircle();

           myCircles[i].setRadius(random.nextInt(100));

           System.out.printf("Created MyCircle %d with radius %.2f \n", i, myCircles[i].getRadius());

       }

       System.out.printf("\nAverage radius of %d circles is %.2f \n", N, MyCircle.averageRadius(myCircles));

   }

}

The output was:

Created MyCircle 0 with radius 76.00

Created MyCircle 1 with radius 86.00

Created MyCircle 2 with radius 38.00

Created MyCircle 3 with radius 4.00

Created MyCircle 4 with radius 8.00

Created MyCircle 5 with radius 39.00

Created MyCircle 6 with radius 77.00

Created MyCircle 7 with radius 78.00

Created MyCircle 8 with radius 39.00

Created MyCircle 9 with radius 46.00

Average radius of 10 circles is 49.10

You might be interested in
E-banking is also called: [1]
DENIUS [597]
Answer 1 it’s online banking
3 0
2 years ago
What is the HTML tag used to define a block of content?<br> O <br> O class<br> O #id<br> O
allsm [11]
Are there any other options
7 0
2 years ago
Read 2 more answers
An administrator needs to set up an authentication server for users connecting to a network through a VPN. What kind of server c
nalin [4]

Answer:

RADIUS

Explanation:

RADIUS is the networking protocol that is used for the purpose of authentication to access the network resources. The full form of RADIUS is Remote Authentication Dial In User Service. It is used by different organizations, which setup their own network that can be accessible through VPN, DSL or modems through different networks. The purpose of this protocol is to establish the security and authentication mechanism by organization itself.

So, If an administrator needs to set up an authentication server for users connecting to a network through a VPN, he should establsih the RADIUS based Server.

3 0
3 years ago
What file can you edit on a linux system to configure shared folders using samba?
TiliK225 [7]

/etc/samba/smb.conf is the file you can edit on a linux system to configure shared folders using samba.

<h3>What is a Linux system ?</h3>
  • A Unix-like operating system (OS) for desktops, servers, mainframes, mobile devices, and embedded devices, Linux is open source and user-developed.
  • One of the most broadly supported operating systems, it is supported on virtually all popular computing platforms, including x86, ARM, and SPARC.
  • Windows OS is a for-profit operating system, whereas Linux is an open-source alternative. In contrast to Windows, which lacks access to the source code, Linux allows users to modify the code as needed.
  • Applications, interfaces, programs, and software are all produced through Linux programming. Desktops, real-time apps, and embedded devices frequently employ Linux code.
  • Programmers can learn about the Linux kernel for free online, enabling them to use, modify, and develop Linux without restriction.

Learn more about linux system refer to :

brainly.com/question/25480553

#SPJ4

6 0
1 year ago
Choose the correct answer base on the Components of Computer System
kondor19780726 [428]
1 - b - Excel is a computer program, so it'd be Software
2 - a - Process of elimination, haven't heard of the term 'peopleware' before.
3 - d - A joystick accepts input from a user to interact with a computer. ex. Flight Simulators
4 - c - A monitor will display (or output) an image based on what is received from the computer.
4 0
3 years ago
Other questions:
  • A disk rotates at a rate of 7200 revolutions per minute. Seek operations (i.e., moving the access head to a desired track) take
    6·1 answer
  • I have a problem with importing excel file into Access. I have some table in Excel and I want to import it into Access. When I d
    6·2 answers
  • You are to create a program using Python that asks the user for a nonnegative number, then computes the mean and variance using
    15·1 answer
  • Which term describes the situation wherein a jury fails to reach a unanimous verdict? A occurs when a jury cannot reach a unanim
    14·1 answer
  • How can you tell that you're driving in the right direction?
    14·1 answer
  • PLEASE HELP!! Kou converged his Word document to a PowerPoint document. When he received the PowerPoint, he was missing material
    12·1 answer
  • Tim has several workbooks open in the Excel application. He would like to view them all at the same time, so he should use the _
    14·1 answer
  • Help plz!! I will mark brainliest
    15·2 answers
  • How does the computer help me with school work
    5·2 answers
  • When you save a presentation with a .potx file extension, which type of powerpoint file is created?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!