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: need some help please

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default need some help please

    Hi
    I'm working on creating a program for a grade processor. The end result is to determine the highest scaled and unscaled scores, I have included a copy of the sample data file that i'm using for input. I do not want to hard code the data file other than the scale factors which are defined in the code. And the output will display the name and two scores, which I have coded. Im having some issues with the logic in the main to calculate the final output.
    Any input on direction would be a great help.

    Sample Data File

    Name Part 1 Part 2 Part 3 Part 4 Total Test Score
    =============== ======== ======== ======== ======== ======== ======== ========
    John Doe 12.20 8.50 3.14 2.30 26.14 1 31.63
    Jane Jones 3.80 7.50 6.30 8.40 26.00 2 20.80
    Jill Jensen 5.60 8.90 3.20 1.50 19.20 3 21.12
    Paul Peterson 9.00 1 1.20 8.50 9.30 38.00 1 45.98

    The contents of the first five columns are the name of the student and the corresponding score they received in each of the four parts of the test. The next column is the total of the points received by the student in the four parts. It is followed by a column indicating the version of the test taken by the student. The final column is the adjusted score computed based on the version of the exam taken by the student(multiplied the total score with the scale factor for the corresponding exam adjustment factor)

    Exam Version Scale Factor
    ============ ============
    1 1.21
    2 0.80
    3 1.10

    ANY EXAM VERSION OTHER THAN 1,2 OR 3 IS NOT TO BE SCALED (OR SCALE IS 1.0)

    --------My code so far--------------------------


    import java.io.File;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.text.DecimalFormat;
    import java.util.Scanner;

    import javax.swing.JOptionPane;

    public class GradeProcessorTwo
    {

    public static void main(String []args) throws IOException

    {

    DecimalFormat gradeFormat = new DecimalFormat("#,#0");
    final String SENTINEL = "END";

    // Set the constants which will be used to determine adjust grades
    final float ScaleFactor_1 = 1.21F;
    final float ScaleFactor_2 = 0.80F;
    final float ScaleFactor_3 = 1.10F;
    double scaledScore = 0;
    double total = 0;


    int currentMaxRawScore = 0; // The current high score
    String maxScoreReport = "";

    // Get the location of the input file and open
    String inputFileName;
    inputFileName = JOptionPane.showInputDialog("Enter the name of the file containing grade data");

    File inputFile = new File(inputFileName);
    Scanner input = new Scanner (inputFile);

    // Print the header to the console
    System.out.printf("%-15s %8s %8s %8s %8s %8s %8s %8s\n", "Name", "Part 1", "Part 2", "Part 3", "Part 4", "Total", "Test #", "Score");
    System.out.printf("%-15s %8s %8s %8s %8s %8s %8s %8s\n", "===============", "========", "========", "========", "========", "========","========","========");

    while(input.hasNext())//read next data
    {

    String name = input.nextLine(); //read the name
    int version = input.nextInt(); //read the test number
    if( name.equals(SENTINEL))

    break;
    {

    String test = input.nextLine();
    int score = input.nextInt();
    String maxScore;

    if (score > currentMaxRawScore) //currentMaxScore = score;
    {

    currentMaxRawScore = score; //highest unadjusted score

    float Score; // determine high scaled score from data file

    if (version ==1)
    scaledScore= currentMaxRawScore * ScaleFactor_1;

    else if (version ==2)

    scaledScore= currentMaxRawScore * ScaleFactor_2;

    else if (version ==3)
    scaledScore= currentMaxRawScore * ScaleFactor_3;

    input.nextLine();

    }

    fileOut.flush();
    fileOut.close();
    input.close();

    JOptionPane.showMessageDialog(null, maxScoreReport = (name + " has highest raw score of "+ currentMaxRawScore+"and adjusted score of"+scaledScore);
    }

    }

    }

    }

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: need some help please

    Im having some issues with the logic in the main to calculate the final output.
    Can you explain what your problems are?
    What is your design/logic for calculating the final output?

    Also please wrap your posted code in code tags to preserver formatting. See:BB Code List - Java Forums
    Or use the Go Advanced button and use the # icon above to right.
    Last edited by Norm; July 6th, 2011 at 01:19 PM.