Java programming:
Write a program called Distribution that reads a file of double values into an array and computes and prints the percentage of those numbers within 1 standard deviation (SD), within 2 SDs, and within 3 SDs of the mean.
The program should be modular and should at least contain the main method and a method for computing the above percentages given the numbers, the mean, and the standard deviation. Other required statistics should be computed in their own methods.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Distribution {
public static void main(String args[]){
Scanner scan;
//arraylist of type double
List<Double> input = new ArrayList<Double>();
try{
// Please enter the path of the file name you are trying
// to read double values.
File file = new File("yourfilename/data.txt");
scan = new Scanner(System.in);
// Reading the double values from input file and storing in arraylist of type double
while(scan.hasNextDouble()){
double d = scan.nextDouble();
input.add(d);
}
// Percentage of numbers within 1st SD
double standarddeviation1 = calculateStandardDeviation(input);
System.out.println("Standard deviation of numbers is " + standarddeviation1);
double percentagewithSD1 = (calculatenumberswithinSD(input,standarddeviation1) / input.size()) * 100;
System.out.println("Percentage of numbers below Standard deviation 1 is " + percentagewithSD1);
// Percentage of numbers within 2nd SD ==> 2 times SD
double standarddeviation2 = 2 * calculateStandardDeviation(input);
System.out.println("Standard deviation of numbers in 2 SDis " + standarddeviation2);
double percentagewithSD2 = (calculatenumberswithinSD(input,standarddeviation2) / input.size()) * 100;
System.out.println("Percentage of numbers below within 2 Standard Deviation is " + percentagewithSD2);
// Percentage of numbers within 3rd SD ==> 3 times SD
double standarddeviation3 = 3 * calculateStandardDeviation(input);
System.out.println("Standard deviation of numbers within 3 SDs of mean" + standarddeviation3);
double percentagewithSD3 = (calculatenumberswithinSD(input,standarddeviation3) / input.size()) * 100;
System.out.println("Percentage of numbers below within 3 Standard Deviation of mean is " + percentagewithSD3);
} catch (Exception e1) {
e1.printStackTrace();
}
}
public static double calculateStandardDeviation(List<Double> dot){
double total = 0.0, standardDeviation = 0.0;
int length = dot.size();
for(double num : dot) {
total += num;
}
//Calculating the average
double mean = total/length;
for(double num: dot) {
standardDeviation += Math.pow(num - mean, 2);
}
//returning the standard deviation
return Math.sqrt(standardDeviation/length);
}
//Generic method to calculate the number of array elements below the standard deviation
public static int calculatenumberswithinSD(List<Double> input,double standarddeviation){
int totalnumbersbelowstandarddeviation=0;
for(double num1: input) {
if(num1 < standarddeviation){
totalnumbersbelowstandarddeviation++;
}
}
return totalnumbersbelowstandarddeviation;
}
}
Java programming: Write a program called Distribution that reads a file of double values into an...
Here is the Prompt for problem 1:
Write a C++ program that reads in a test file. The first number
in the file will be an integer, and will indicate the amount of
decimal numbers to follow. Once you have the read the numbers from
the file into an array then compute the following properties on the
set of numbers: the sum, the average (mean), the variance, the
standard deviation, and the median. Don’t try to do the entire
program...
JAVA Programming
Produce a method that reads in a set of values (double) from the
user and returns them. Use this header:
public static double[] getNumsFromUser(String msg1,
String msg2)
The implementation of the method should start with a message to
input the total number of array elements, followed by a message to
enter all the array elements. The method returns the array of
elements. The two strings msg1 and msg2 that are passed to the
method as parameters will be...
Need help figuring this out Write a program that reads in a sequence of numbers (doubles) from standard input until 0 is read, and stores them in an array, This part is done using iteration (loop). You may assume that the maximum size of the array will not be more than 100. Your program computes the maximum number stored in the array, the count of negative numbers, and computes the sum of positive numbers, using recursion. You need to have...
In Java*
Write a program that reads an arbitrary number of 20 integers that are in the range 0 to 100 inclusive. The program will ask a user to re-enter an integer if the user inputs a number outside of that range. The inputted integers must then be stored in a single dimensional array of size 20. Please create 3 methods: 1. Write a method public static int countEven(int[] inputArray) The method counts how many even numbers are in...
1.Write a Java program that computes the average of the values of a row in a twodimensional array. You should create a method with the following header: public static double averageRow(double[][] array, int row) Write a test program that reads a matrix from the user and a row index to calculate the average on. Print the result. 2.A square matrix is said to be an upper triangular matrix if the value of the cell is 0 when row > column....
Write a complete Java program in a file caled Module1Progrom.java that reads all the tokens from a file named dota.txt that is to be found in the same directory as the running program. The program should ignore al tokens that cannot be read as an integer and read only the ones that can. After reading all of the integers, the program should print all the integers back to the screen, one per line, from the smalest to the largest. For...
Write a program that reads a file named input.txt and writes a file that contains the same contents, but is named output.txt. The input file will contain more than one line when I test this. Do not use a path name when opening these files. This means the files should be located in the top level folder of the project. Do not use a copy method that is supplied by Java. Your program must read the file line by line...
write in c programming
Write a C program that reads in up to 10 numbers into an array. The program should count the number of duplicate elements within that array and print the result. Example test data and expected output is given below Test Data: [2,1,1,2,1,3, 4] Duplicates:
public static double[] getVolumes(double[] base, double[] height, double[] length) Write a Java program called TriangularPrisms which does the following: In the main method: Use a for loop which repeats three times. Within the loop, a. prompt the user to enter the base of the triangular prism and store the value in a double array called base b. prompt the user to enter the corresponding height and store the value in a double array called height c. prompt the user to...
Write a Java program that reads a file until the end of the file is encountered. The file consists of an unknown number of students' last names and their corresponding test scores. The scores should be integer values and be within the range of 0 to 100. The first line of the file is the number of tests taken by each student. You may assume the data on the file is valid. The program should display the student's name, average...