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
denpristay [2]
3 years ago
15

1. The following programs require using arrays. For each, the input comes from standard input and consists of N real numbers bet

ween 0.0 and 1.0. \ a. Print the median element. b. Print the element that occurs most frequently. c. Print the element closest to 0. d. Print all the numbers greater than the average. e. Print the N elements in random order. f. Print histogram (with, say 10 bins of size 0.1).
Computers and Technology
1 answer:
Mamont248 [21]3 years ago
3 0

Answer:

import java.util.*;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.util.Arrays;

class GFG

{

  // Function for calculating mean

  public static double findMean(double a[], int n)

  {

      int sum = 0;

      for (int i = 0; i < n; i++)

          sum += a[i];

 

      return (double)sum / (double)n;

  }

  // Function for calculating median

  public static double findMedian(double a[], int n)

  {

      // First we sort the array

      Arrays.sort(a);

      // check for even case

      if (n % 2 != 0)

      return (double)a[n / 2];

 

      return (double)(a[(n - 1) / 2] + a[n / 2]) / 2.0;

  }

  public static double findMode(double a[], int n)

{

// The output array b[] will

// have sorted array

//int []b = new int[n];

 

// variable to store max of

// input array which will

// to have size of count array

double max = Arrays.stream(a).max().getAsDouble();

 

// auxiliary(count) array to

// store count. Initialize

// count array as 0. Size

// of count array will be

// equal to (max + 1).

double t = max + 1;

double[] count = new double[(int)t];

for (int i = 0; i < t; i++)

{

count[i] = 0;

}

 

// Store count of each element

// of input array

for (int i = 0; i < n; i++)

{

count[(int)(10*a[i])]++;

}

 

// mode is the index with maximum count

double mode = 0;

double k = count[0];

for (int i = 1; i < t; i++)

{

if (count[i] > k)

{

k = count[i];

mode = i;

}

}

return mode;

}

public static double findSmallest(double [] A, int total){

Arrays.sort(A);

return A[0];

}

 

public static void printAboveAvg(double arr[], int n)

{

 

// Find average

double avg = 0;

for (int i = 0; i < n; i++)

avg += arr[i];

avg = avg / n;

 

// Print elements greater than average

for (int i = 0; i < n; i++)

if (arr[i] > avg)

System.out.print(arr[i] + " ");

System.out.println();

}

 

public static void printrand(double [] A, int n){

Arrays.sort(A);

for(int i=0;i<n;i++){

System.out.print(A[0]+"/t");

}

System.out.println();

}

 

public static void printHist(double [] arr, int n) {

 

for (double i = 1.0; i >= 0; i-=0.1) {

System.out.print(i+" | ");

for (int j = 0; j < n; j++) {

 

// if array of element is greater

// then array it print x

if (arr[j] >= i)

System.out.print("x");

 

// else print blank spaces

else

System.out.print(" ");

}

System.out.println();

}

// print last line denoted by ----

for(int l = 0; l < (n + 3); l++){    

System.out.print("---");

}

 

System.out.println();

System.out.print(" ");

 

for (int k = 0; k < n; k++) {

System.out.print(arr[k]+" ");

}

}

  // Driver program

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

  {

      //Enter data using BufferReader

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

double [] A = new double[100];

int i=0;

System.out.println("Enter the numbers(0.0-1.0) /n Enter 9 if u have entered the numbers. /n");

do

{

A[i++]=Double.parseDouble(br.readLine());

}while(A[i-1]==9);

      i--;

      System.out.println("Average = " + findMean(A,i) );

      System.out.println("Median = " + findMedian(A,i));

      System.out.println("Element that occured most frequently = " + findMode(A,i));

      System.out.println("number closest to 0.0 =" + findSmallest(A,i));

      System.out.println("Numbers that are greater than the average are follows:");

      printAboveAvg(A,i);

      System.out.println("Numbers in random order are as follows:");

      printrand(A,i);

      System.out.println("Histogram is bellow:");

      printHist(A,i);

  }

}

Explanation:

You might be interested in
Zoom Vacuum, a family-owned manufacturer of high-end vacuums, has grown exponentially over the last few years. However, the comp
Sati [7]

Answer:

The best advice for Zoom Vacuum is  to start with a Transaction Processing System(TPS). This system will process all the day to day transactions of the system. It is like a real time system where users engage with the TPS and generate, retrieve and update the data. it would be very helpful in lowering the cost of production and at the same time manufacture and produce standard quality products.

Although, TPS alone would not be sufficient enough. so Management Information System(MIS) would be needed, that can get the data from the TPS and process it to get vital information.

This MIS will bring about information regarding the sales and inventory data about the current and well as previous years.

With the combination of TPS as well as MIS is a minimum requirement for a Zoom Vacuum to become successful in the market.

Explanation:

Solution

When we look at the description of the Zoom Vacuum manufacturing company closely, we see that the business is currently a small scale business which is trying to become a small to mid scale business. This claim is supported by the fact that there is only one manufacturing plant and three warehouses. And here, we also need to have the knowledge of the fact that small business major aim is to keep the cost low and satisfy the customers by making good products. So we need to suggest what information system is best suited for small scale business enterprises.

The best recommendation would be to start with a Transaction Processing System(TPS). This system will process all the day to day transactions of the system. It is like a real time system where users interact with the TPS and generate, retrieve and modify the data. This TPS would be very helpful in lowering the cost of production and at the same time manufacture and produce standard quality products . Also TPS can help in communicating with other vendors.

But TPS along would not be sufficient. Also Management Information System(MIS) would be required that can get the data from the TPS and process it to get vital information. This MIS will help in generating information regarding the sales and inventory data about the current and well as previous years. Also MIS can create many types of graphical reports which help in tactical planning of the enterprise.

So a combination of TPS as well as MIS is a minimum requirement for a Zoom Vacuum to become successful in the market.

7 0
3 years ago
How to shutdown a computer by step by step​
Reptile [31]

<u><em> </em></u>Answer:

1) Press Ctrl + Alt + Del

2) Click the power button in the bottom-right corner of the screen.

3) From the desktop, press Alt + F4 to get the Shut Down Windows screen.

and that's how to shut down your computer

<u><em></em></u>

<u><em>Please mark as brainliest if answer is right</em></u>

Have a great day, be safe and healthy  

Thank u  

XD  

7 0
2 years ago
Read 2 more answers
Which part of a computer is responsible for executing the software programs?
mamaluj [8]

Answer:

c. CPU

Explanation:

7 0
3 years ago
Review the HTML tags that we have gone over in this lesson. Research HTML tags on the web and identify two new tags. Use these t
NemiM [27]

Answer:

w3schools

Explanation:

there is a webiste called w3schools that really helped me through my web page design class, just click on learn html

4 0
3 years ago
You can use the ____ to change the order of the wat windows are stacked.
djyliett [7]

Answer:

A

Explanation:

6 0
3 years ago
Other questions:
  • Random-access memory (RAM) is able to quickly access data because it is arranged in which of the following configurations?
    8·2 answers
  • How to connect to my wireless printer for dummies?
    12·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    11·1 answer
  • In how many sections is the Add Animation pane divided? What is the utility of each section?​
    8·2 answers
  • Consider the following code segment. int[] seq = {3, 1, 8, 4, 2, 5}; for (int k = 1; k &lt; seq.length; k++) { if (seq[k] &gt;=
    5·1 answer
  • It is possible to limit the search results to a range of publication dates.
    13·1 answer
  • Encryption is an important topic in math and computer science. It keeps your personal information safe online.
    6·1 answer
  • Which of the following statements is FALSE?
    5·1 answer
  • There is a file of a few Sean Connery movies on the internet. Each entry has the following form:
    9·1 answer
  • Different Betweens ServerPc And Desktop Pc ~
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!