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
Select the correct answer from each drop-down menu.
Gelneren [198K]

Answer:

Maybe computer engineering and marketing skills

4 0
3 years ago
Which cpu type would most likely be found in a smartphone?.
dlinn [17]

Answer:

dual-core (two), quad-core (four) and octa-core (eight)

Explanation:

These are the most common according to my research.

If I helped you, can I please have brainliest?

Have a great day/night!

4 0
2 years ago
When engineers consider _____, they propose giving up a benefit of one proposed design in order to obtain a benefit of a differe
spin [16.1K]

Answer:

The answer is A. Constraint.

5 0
2 years ago
What statement best describes Konrad Zuse?
vazorg [7]

Answer:

D

Explanation:

Konrad Zuse was a German civil engineer, inventor and computer pioneer. His greatest achievement was the world's first programmable computer; the functional program-controlled Turing-complete Z3 became operational in May 1941.

8 0
3 years ago
Read 2 more answers
A hotel salesperson enters sales in a text file. Each line contains the following, separated by semicolons: the name of the clie
timama [110]

Answer:

see explaination

Explanation:

Java code

//Header file section

import java.util.Scanner;

import java.io.*;

//main class

public class SalesTestDemo

{

//main method

public static void main(String[] args) throws IOException

{

String inFile;

String line;

double total = 0;

Scanner scn = new Scanner(System.in);

//Read input file name

System.out.print("Enter input file Name: ");

inFile = scn.nextLine();

FileReader fr = new FileReader(new File(inFile));

BufferedReader br = new BufferedReader(fr);

System.out.println("Name \t\tService_Sold \tAmount \tEvent Date");

System.out.println("=====================================================");

line = br.readLine();

//Each line contains the following, separated by semicolons:

//The name of the client, the service sold

//(such as Dinner, Conference, Lodging, and so on)

while(line != null)

{

String temp[] = line.split(";");

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

{

System.out.print(temp[i]+"\t");

if(i == 1)

System.out.print("\t");

}

//Calculate total amount for each service category

total += Double.parseDouble(temp[2]);

System.out.println();

line = br.readLine();

}

//Display total amount

System.out.println("\nTotal amount for each service category: "+total);

}

}

inputSale.txt:

Peter;Dinner;1500;30/03/2016

Bill;Conference;100.00;29/03/2016

Scott;Lodging;1200;29/03/2016

Output:

Enter input file Name: inputSale.txt

Name Service_Sold Amount Event Date

=====================================================

Peter Dinner 1500 30/03/2016

Bill Conference 100.00 29/03/2016

Scott Lodging 1200 29/03/2016

Total amount for each service category: 2800.0

3 0
3 years ago
Other questions:
  • When looking through the documentation for a specific class, you never actually see the source code for that class. Instead, you
    6·1 answer
  • Identify the mobile device deployment option that gives the user flexibility to select a device, but allows the company to contr
    5·1 answer
  • 6.
    14·2 answers
  • How many hosts are in each subnet?
    15·1 answer
  • Read first a user's given name followed by the user's age from standard input. Then use an ofstream object named outdata to writ
    6·1 answer
  • Select the correct answer.
    13·1 answer
  • How many miss Dragon Ball Abridged?
    5·2 answers
  • Write bash script which takes array as an input of size 10 bind its even indexes to accept even values and odd indexes to accept
    5·1 answer
  • Will mark Brainliest!! What is the best hard disk compacity? Why?
    7·1 answer
  • What are the importance of computer software​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!