Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: java file processing beginner level

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default java file processing beginner level

    INFO ABOUT THE PROGRAM
    /*
    dive_data.txt info
    1 3.5 5.5 6.0 7.0 6.5 6.5 5.5 7.5
    2 2.0 8.0 8.5 8.5 9.0 8.0 8.5 8.0
    I already got rid of 1 because it was an int, and the teacher said to remove the int, but I can't get rid of 3.5.
    I want to get rid of 3.5 and store in in a variable. so my math.min is 5.5 instead of 3.5
    I'm having a hard time picking doubles from doubles.
    sorry first time using this website so im kind of disorganized.

    */
    public static double calculateOneScore(String diveLine) { // calculate each
    // diver score
    Scanner console = new Scanner(diveLine); // store diveline in console
    double max = 0.0; // hold the maximum for a line of score
    double min = 10; // hold the minimum for a line of score
    double sum = 0.0; // hold the sum of all score
    double num = 0.0; // num store next double line of file score
    double difficulty = 0.0; // store the difficulty score
    while (console.hasNextInt()) {
    int diverNum = console.nextInt();

    while (console.hasNextDouble()) { // test if the file line as a
    num = console.nextDouble(); // store double in num
    if (num <= 4) { // test the difficulty
    difficulty = num; // store difficulty num
    }
    sum += num; // add sum to num and store in sum
    max = Math.max(max, num); // get the max number
    min = Math.min(min, num); // get minimum
    }
    }
    sum = sum - (max + min);
    sum = sum * difficulty * 0.6;
    return sum;
    }


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: java file processing beginner level

    Please consider taking time to write a few sentences about your problem and posting it here. The better we can understand the issues you face, the better we'll be able to help you.

Similar Threads

  1. Creating a Simple, Beginner-Level Vowel Counter
    By tryingtolearn in forum Collections and Generics
    Replies: 1
    Last Post: July 8th, 2012, 03:25 PM
  2. Replies: 1
    Last Post: April 18th, 2012, 01:12 PM
  3. Beginner - how to make .java file run!
    By javahelp2012 in forum JDBC & Databases
    Replies: 3
    Last Post: March 27th, 2012, 01:34 PM
  4. Quick, beginner-level Java question.
    By DHG in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 27th, 2011, 01:06 PM
  5. ERROR WHILE PROCESSING JSF FILE
    By Pankaj in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: July 10th, 2010, 12:42 AM