Write a program that will find the standard deviation of a list of numbers found
ID: 3819258 • Letter: W
Question
Write a program that will find the standard deviation of a list of numbers found in a file. Input Validation: No input validation required. Assume the input file will have the correct type of data. Requirements: The program must ask the user for the name of the file. You must have a method with the following header: public static double deviation (File inputFile) This method will take a File object as input and use File I/O to calculate and return the standard deviation of a series of numbers found inside of a file. You should create your own test files to test the functionality of your program. Sample Execution: Enter the name of the file: my_numbers.txt The standard deviation of the values in this file is: 78.29Explanation / Answer
standard derivation number of alist of of found in a file:
import java.io.*;
public class Test2 {
public void check(String fname) {
System.out.println("Filename-->"+fname);
try {
BufferedReader in = new BufferedReader(new FileReader(fname));
String str;
while ((str = in.readLine()) != null) {
System.out.println(str);
}
in.close();
} catch (IOException e) {
}
}
/**
22
* @param args the command line arguments
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Missing filename argument");
System.out.println("");
System.out.println("StatAnal <fname>");
System.out.println("");
} else {
String filename = args[0];
Test2 sa = new Test2();
sa.check(filename);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.