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
irga5000 [103]
1 year ago
6

Variance for accumulator. Validate that the following code, which adds the

Computers and Technology
1 answer:
Art [367]1 year ago
3 0

Using the knowledge of computational language in JAVA it is possible to write a code that Validate that the following code, which adds the methods var() and stddev() to Accumulator, computes both the mean and variance of the numbers presented as arguments to addDataValue()

<h3>Writting the code:</h3>

<em>import java.util.*;</em>

<em>public class </em><em>Accumulator </em><em>{  </em>

<em>private static double m;   </em>

<em>private static double v;   </em>

<em>private static double st;   </em>

<em>private static  double s[]=new double[5]; </em>

<em>private static int N;</em>

<em>private static int count =0;</em>

<em>public static void main(String[] args) {</em>

<em>// TODO Auto-</em><em>generated </em><em>method stub</em>

<em>Random r = new Random();</em>

<em>System.out.println("hello world");</em>

<em>for(int i=0;i<5;i++) {</em>

<em>    double randomvalue = r.nextDouble();</em>

<em>addDataValue(randomvalue);</em>

<em>}</em>

<em>for(int i=0;i<s.length;i++) {</em>

<em>    System.out.println("dataValue:"+s[i]);</em>

<em>}   </em>

<em>mean();</em>

<em>System.out.println("mean:"+m);</em>

<em>var();</em>

<em>System.out.println("variance:"+v);</em>

<em>stddev();</em>

<em>System.out.println("standard deviation:"+st);</em>

<em>}</em>

<em>public  static void </em><em>addDataValue</em><em>(double value) {     // addes data values to array</em>

<em>  s[count]=value;</em>

<em>  count++;</em>

<em> }</em>

<em>public static double mean() {        // returns mean</em>

<em>double sum=0.0;</em>

<em>for(int i=0;i<s.length;i++) {</em>

<em>    sum+=s[i];</em>

<em>}</em>

<em>m = sum/s.length;</em>

<em> return m;</em>

<em>}   </em>

<em>public </em><em>static </em><em>double var() {    //returns variance</em>

<em>double mm = mean();</em>

<em>     double t = 0;</em>

<em>     for(int i=0;i<s.length;i++) {</em>

<em>         t+= (s[i]-mm)*(s[i]-mm);</em>

<em>} </em>

<em>     v= t/(s.length-1);</em>

<em>      return v;  </em>

<em>}</em>

<em>public static  double </em><em>stddev</em><em>() {        // returnsn the stardard deviation </em>

<em>st= Math.sqrt(var());</em>

<em>return st;</em>

<em>}</em>

<em>}</em>

See more about JAVA at brainly.com/question/12975450

#SPJ1

You might be interested in
True / False<br> General purpose registers can be read and written by ML programs
Oduvanchick [21]

Answer: False

Explanation:

  General purpose register cannot be read and written by the Ml program because when ever the instruction decode the input and output unit are invoke for data to read in the memory and it can written to the output device from the memory. General purpose register stored both the addresses and the data in the file. In some cases ML only reads with the hep of special algorithm function.

6 0
3 years ago
Protocols used in each layers in each osi reference model
natka813 [3]

The protocols  that are often used in each layers in each OSI reference model are:

Layers                           Protocols

Layer 7- Application          SMTP, HTTP, FTP, POP3, SNMP

Layer 6- Presentation           MPEG, ASCH, SSL, TLS

Layer 5-Session                   NetBIOS, SAP

Layer 4-Transport                      TCP, UDP

Layer 3-Network                IPV5, IPV6, ICMP, IPSEC, ARP, MPLS.

Layer 2-Data Link       RAPA, PPP, Frame Relay, ATM, Fiber Cable.

Layer 1-Physical              RS232, 100BaseTX, ISDN, 11.

<h3>What is OSI Model?</h3>

The OSI Model is known to be a kind of a logical and conceptual framework that tells all about network communication that is often used by systems in an open to interconnection and also in any communication with other forms of systems.

Note that the Open System Interconnection (OSI Model) is one that tells more about a logical network and it is one that also tells about computer packet transfer via the use of various layers of protocols.

Therefore, The protocols  that are often used in each layers in each OSI reference model are:

Layers                           Protocols

Layer 7- Application          SMTP, HTTP, FTP, POP3, SNMP

Layer 6- Presentation            MPEG, ASCH, SSL, TLS

Layer 5-Session                   NetBIOS, SAP

Layer 4-Transport                      TCP, UDP

Layer 3-Network                IPV5, IPV6, ICMP, IPSEC, ARP, MPLS.

Layer 2-Data Link       RAPA, PPP, Frame Relay, ATM, Fiber Cable.

Layer 1-Physical              RS232, 100BaseTX, ISDN, 11.

Learn more about OSI reference model  from

brainly.com/question/12976859

#SPJ1

8 0
2 years ago
Which of the following is NOT a characteristic developed by New Journalism?
krok68 [10]
Flashy page layouts
7 0
3 years ago
Look at the following description of a problem domain:The bank offers the following types of accounts to its customers: saving a
Alchen [17]

Answer:

The answers are explained below

Explanation:

1) Identify the potential classes in this problem domain be list all the nouns

class Customer

class Acco  unt

2) Refine the list to include only the necessary class names for this problem

the class customer is not necessary to solve the problem itself, therefore the only class could be the account class

3) Identify the responsibilities of the class or classes.

The responsibilities of the class account will be

* determination of the type of account--> Acc  ount . type(char)

*  deposit money into the account --> Acc  ount . de posit(float)

* withdraw money into the account --> Acc  ount . with draw(float)

* show balance of the account --> Acc  ount . bal ance()

* generate interest --> Acc  ount . int erest()

Please join the words together. I used spaces due to regulations

5 0
4 years ago
Multinational corporations use __ to share their resources with all their employees because it __
Liono4ka [1.6K]
First B
Second A
Seems like the best answers
4 0
3 years ago
Other questions:
  • After configuring a static IP address on a desktop computer, the technician finds that he cannot communicate with other devices
    10·1 answer
  • Which are appropriate uses for special effects in presentations?
    14·1 answer
  • Word processing software, spreadsheet software, database software, and presentation software are examples of what category of co
    12·1 answer
  • What is one disadvantage of accessing the Internet through a public search engine such as Google or Yahoo?
    10·2 answers
  • The __________ assumption necessary for a linear programming model to be appropriate means that the contribution to the objectiv
    6·1 answer
  • I need help!
    14·1 answer
  • Which page feature is used in long documents to assist readers in quickly finding information in the document without having to
    11·2 answers
  • Each web site contains a(n) ____ page, which is the first document users see when they access the site.
    9·1 answer
  • What variation pairs a new employee with an employee who has been with the company for 20 years?
    6·2 answers
  • LAB: Parsing dates Complete main() to read dates from input, one date per line. Each date's format must be as follows: March 1,
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!