StatsDemo.java - import java.text.DecimalFormat/for number...

Info icon This preview shows pages 1–2. Sign up to view the full content.

import java.text.DecimalFormat; //for number formatting import java.util.Scanner; //for keyboard input import java.io.*; // for file input and output public class StatsDemo { public static void main(String [] args) throws IOException //ADD A THROWS CLAUSE HERE - throws IOException { double sum = 0; //the sum of the numbers int count = 0; //the number of numbers added double mean = 0; //the average of the numbers double stdDev = 0; //the standard deviation of the numbers String line; //a line from the file double difference; //difference between the value and the mean //create an object of type Decimal Format DecimalFormat threeDecimals = new DecimalFormat("0.000"); //create an object of type Scanner Scanner keyboard = new Scanner (System.in); String filename; // the user input file name //Prompt the user and read in the file name System.out.println("This program calculates statistics" + "on a file containing a series of numbers"); System.out.print("Enter the file name: "); // user should enter Numbers.txt filename = keyboard.nextLine(); // Create a file reader FileReader freader = new
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Image of page 2
This is the end of the preview. Sign up to access the rest of the document.
  • Summer '16

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern