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
Sav [38]
3 years ago
7

Questions 6 - 9 Refer to the following code: public class WhatsIt { private int[] values; private double average; public WhatsIt

() { values = new int[10]; findAvg(); } public WhatsIt (int[] n) { values = n; findAvg(); } public void findAvg () { double sum = 0; for (int i = 0; i < values.length; i++) { sum += values[i]; } average = 1.0 * sum / values.length; } public String toString() { return "Average: " + average + " Length: " + values.length; } } What does the line findAvg(); in the constructor do? Creates a reference to the average variable. Calls the method findAvg() so the variable average is updated correctly. Calls the constructor findAvg; so the object can be created in memory. This call should be removed. Checks to see if the average variable has been initialized
Computers and Technology
1 answer:
gavmur [86]3 years ago
4 0

Answer:

class WhatsIt

{

private static int [] values;

private double average;

public Double Average=average;

public WhatsIt () {values = new int [10]; findAvg(); }

public WhatsIt (int [] n) {values = n; findAvg(); }

public static void findAvg ()

{double sum = 0;

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

{sum += values[i]; }

average = 1.0 * sum / values.length;

System.out.println(Average);

System.out.println(average);

}

public static String ToString()

{

   System.out.println(average); System.out.println(values.length);

   return "Average: " + average + " Length: " + values.length;

}

public static void main(String[] args)  

{

    //WhatsIt();

    //ToString();

    findAvg();

}

}

The findAvg() calculates the average.

The reference to average is defined as below:

public double Average=average;

And when we call findAvg average is initialized, and Average is also initialized, which we can check through println statement.

Explanation:

Please check the answer section.

You might be interested in
What X coordinate does the center of a game begin at?
kotegsom [21]

A. 0

I am not entirely sure, I am not much of a coder(well I am but I don’t code often) so I hope this helps!

5 0
3 years ago
The ability for new computers to be automatically connected to the network is provided by the:________
Brrunno [24]

Answer:

DHCP server

Explanation:

5 0
2 years ago
Recently, Walmart offered a wireless data contract based on bandwidth used, with a minimum monthly charge of $42 for up to 5 gig
nekit [7.7K]

Answer:

For 9GB of data the user would pay $82 monthly!

Explanation:

To start off, our end goal is 9GB. We have the equation 9 = ? We can add up to our solutions with 1GB, 3GB, and 10GB. We can immediately rule out 10GB, since 9GB ≠ 10GB. To cost the least amount of money we can add up             3GB and 1GB = 4GB + 5GB = 9GB!

So, our equation is 3GB + 1GB + 5GB = 9GB, now lets figure out the cost!

                                $28 + $12 + $42 = $82

For 9GB of data the user would pay $82 monthly!

Hope this Helps! :)

<em>Have any questions? Ask below in the comments and I will try my best to answer. </em>

-SGO

7 0
3 years ago
You are making a game! The player tries to shoot an object and can hit or miss it. The player starts with 100 points, with a hit
Anni [7]

The program illustrates the use of loops and conditions.

Loops are used for repetitions, while conditions are used to make decisions

The game program in Python, where comments are used to explain each line is as follows:

#This initializes the point to 100

point = 100

#The following loop is repeated 4 times

for i in range(4):

   #This gets the current action

   action = input("Hit or Miss: ")

   #This following if statement calculates the point

   if action.lower() == "hit":

       point+=10

   else:

       point-=20

#This prints the calculated point

print(point)

Read more about loops and conditions at:

brainly.com/question/14284157

3 0
3 years ago
You need to design an online login form in which users have to type their name and password to log into an application. The pass
Elena L [17]
Well, it depends if we are talking about the front end(HTML / Javascript) which grabs the data or are we taking about the back end such as php code or are we talking about the database that stores the password. Either case it is going to be a text/String field of some sort. For instance, the <input> field is going to be a text type but in a form of type="password". On the server side such as php, the code will grab this as a String type and encrypt it. 
7 0
4 years ago
Read 2 more answers
Other questions:
  • Create a stack with three integers and then use .toarray to copy it to an array.
    10·1 answer
  • If you decide to get married, a trade-off would be that you have to give up being single.
    12·2 answers
  • Which is a correct way to test whether two variables representing numbers, numOne and numTwo, are equal?
    8·1 answer
  • Should a waiting thread receive priority over a thread first attempting to enter a monitor? What priority scheme, if any, should
    9·1 answer
  • Someone, please answer this.
    15·1 answer
  • use the internet to research the SYSTEM account. Why is it nessesary to include this account with full control on a directory
    13·1 answer
  • Does anyone know the name of the font :) ?
    14·2 answers
  • Which guideline would not promote energy conservation?
    15·1 answer
  • What method does a gsm network use to separate data on a channel?
    12·1 answer
  • A _____ consists of horizontal bars, connected with arrows that indicate task dependencies.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!