Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2009
    Posts
    19
    Rep Power
    0

    Default Really need help with an assignment... counter control loop...

    I need help with an assignment...

    I need to:
    Write a stand-alone application that calculates the average of quiz scores. The number of quiz scores is specified by the user; thus, use a counter-controlled loop. Also, enter the student's name and calculate the student's grade based upon:

    A: 90 to 100
    B: 80 to 89
    C: 70 to 79
    D: 60 to 69
    F: 0 to 59

    Thus, the output should look like:

    Student: Scott
    # Quizzes: 4
    Quiz 1: 82
    Quiz 2: 94
    Quiz 3: 90
    Quiz 4: 94
    Average: 90
    Grade: A

    -------------------------------------------------

    Here is what I have:

    -------
    import java.io.*;
    import java.util.*;

    public class exampleStudentGrade
    {
    public static void main(String[] args) throws IOException,
    FileNotFoundException
    {

    //declare and initialize the variables //Step 1
    double test1, test2, test3, test4, test5;
    double average;
    String firstName;
    String lastName;

    Scanner inFile =
    new Scanner (System.in); //Step 2

    PrintWriter outFile = new
    PrintWriter("testavg.out"); //Step 3

    firstName = inFile.next(); //Step 4
    lastName = inFile.next(); //Step 4

    outFile.println("Student Name: "
    + firstName + " " + lastName); //Step 5

    //Step 6 - retrieve the five test scores
    test1 = inFile.nextDouble();
    test2 = inFile.nextDouble();
    test3 = inFile.nextDouble();
    test4 = inFile.nextDouble();
    test5 = inFile.nextDouble();

    outFile.printf("Test scores: %5.2f %5.2f %5.2f "
    + "%5.2f %5.2f %n", test1, test2,
    test3, test4, test5); //Step 7

    average = (test1 + test2 + test3 + test4
    + test5) / 5.0; //Step 8
    outFile.printf("Average test score: %5.2f %n",
    average); //Step 9
    if (average>=90)System.out.println("A");
    else if (average>=80)System.out.print("B");
    else if (average>=70)System.out.print("C");
    else if (average>=60)System.out.print("D");
    else if (average<=50)System.out.print("F");
    inFile.close(); //Step 10
    outFile.close(); //Step 10
    }
    }
    --------------

  2. #2
    MK12's Avatar
    MK12 is offline Senior Member
    Join Date
    Jan 2009
    Posts
    185
    Rep Power
    6

    Default

    Put your code in CODE tags, and tell me specifically what isn't working or what part you are stuck on, and I'll be glad to help as well as many others.
    -MK12
    Tell me if you want a cool Java logo avatar like mine and I'll make you one.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    It's good that you made an effort to solve it first before posting here. Thanks. Now, please clarify exactly what problems you are having. Is your code not compiling? If so, please post the error messages. Is it compiling but throwing an exception? Again, post the exception message, and indicate somehow for both the above which lines are causing the problem.

    Is it that your current code does not fulfill your requirements and if so how, and why do you think it's not working, etc,...

    The more qualit info you give us the greater our ability to help you.

    Good luck.

  4. #4
    Join Date
    Feb 2009
    Posts
    19
    Rep Power
    0

    Default

    right now it runs but it is not exactly what i want - - - - - - I do not know how to: tell the computer (when i am prompted) The number of quiz scores i want to enter - specified by the user; thus, use a counter-controlled loop - and get the read out to read the average ie. the letter grade... it reads out the percentage point but not the letter grde.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You'll use your Scanner object, inFile to get this input. Scanner has a method for getting integer input that's similar to what you're using to get double input. I'd use that to get from the user the test-count, place that into a testCount or similar int variable, and then have a for loop use that variable as part of its ending condition. Good luck.

  6. #6
    Join Date
    Feb 2009
    Posts
    19
    Rep Power
    0

    Default

    ya i dont know a thing u just said... i am not trying to be an ass or anything i just dont understand anything like that... i need major help

  7. #7
    MK12's Avatar
    MK12 is offline Senior Member
    Join Date
    Jan 2009
    Posts
    185
    Rep Power
    6

    Default

    If you don't understand this, you should do things you can understand to work up to being able to code this. Try googling sun java tutorial. That will get you started.
    -MK12
    Tell me if you want a cool Java logo avatar like mine and I'll make you one.

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by maxpower1000sa View Post
    ya i dont know a thing u just said... i am not trying to be an ass or anything i just dont understand anything like that... i need major help
    If this is so, then I hate to say it but you probably need help beyond the abilities of the members of this forum. We can try to guide you, but we can't teach you. Why don't you contact your teacher and try to arrange some one-on-one help?

Similar Threads

  1. Counter
    By ks1615 in forum New To Java
    Replies: 6
    Last Post: 02-20-2009, 03:02 AM
  2. control app width based on certain control
    By thebillybobjr in forum SWT / JFace
    Replies: 0
    Last Post: 05-15-2008, 04:52 PM
  3. Frequency Counter
    By justlearning in forum New To Java
    Replies: 0
    Last Post: 05-07-2008, 10:50 PM
  4. [SOLVED] BST Frequency Counter
    By theonly in forum Advanced Java
    Replies: 7
    Last Post: 04-29-2008, 11:33 PM
  5. Help with static variable counter
    By silvia in forum New To Java
    Replies: 1
    Last Post: 07-19-2007, 07:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •