Results 1 to 2 of 2
- 01-31-2013, 07:59 PM #1
Member
- Join Date
- Jan 2013
- Posts
- 2
- Rep Power
- 0
Read from a text file, then calculate min/max/mode/mean/median...?
Hello, I am required to write a program that reads from a program a list of grades, then outputs the min/max/mode/median/mean of these grades. What am I genuinely confused with is where to start....? I understand the logic behind the mathematics calculations, however, I don't understand how to structure my program. I've created an array with a max amount of grades in the file being 500. Do I create new methods for each calculation (ie: public static int min ( ))? I'm confused, any guidance would be appreciated. Here is my code thus far.
Java Code:import java.util.Scanner; import java.io.*; public class statistics { public static void main (String [] args) { System.out.println("What file contains the data?"); Scanner kbd = new Scanner(System.in); System.out.println("The maximum grade is: "); System.out.println("The minimum grade is: "); System.out.println("The mean grade is: "); System.out.println("The median grade is: "); System.out.println("The modal grade is: "); int [] grades = new int [500]; int count = 0; try { input = new Scanner (new File(file)); } catch(FileNotFoundException e) { System.err.println("Error blah blah blah"); System.exit(0); } while(input.hasNext()) { grades[count] = input.NextInt(); System.out.println(grades[count]); count++; } input.close(); Arrays.sort(grades, 0, count); } }
- 01-31-2013, 08:25 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,394
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
Median and mode HELP!
By Gamedisolver in forum New To JavaReplies: 2Last Post: 10-09-2012, 06:14 AM -
Calculating Median and mode
By rochla16 in forum New To JavaReplies: 4Last Post: 04-29-2011, 04:24 AM -
open a file using read or write mode
By swati.jyoti in forum New To JavaReplies: 2Last Post: 04-25-2009, 04:44 PM -
Open xls file in read-write mode
By rdhaware in forum Advanced JavaReplies: 1Last Post: 02-03-2009, 08:12 AM -
How to Read data from text file and calculate the values?
By janeansley in forum New To JavaReplies: 40Last Post: 07-04-2008, 08:41 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks