Results 1 to 8 of 8
  1. #1
    jmjbreezin is offline Member
    Join Date
    May 2011
    Posts
    3
    Rep Power
    0

    Default Please help - can't seem to correct this...

    Hi, I'm new to Java and I'm having trouble debugging this applet that I have. Can someone please help me. Everytime I debiug it, I ran into errors. Thanks.
    It's a program to create a table of grades for a class.


    // This program creates a table of grades for a class

    import java.util.*;
    public class Class{ Grades
    { // This Program will create a table of grades for a class.
    public static void main(String[] args)
    {
    int Grade, Points, Students;
    double Percent;
    // User input three initials
    String initials = input.next();
    System.out.printf(String "Initials is %s Points is %d Percent is %f Grade is %c, Initials, Points, Percent, Grade);
    Scanner input = new Scanner(System.in);
    // Tell user what this program does
    System.out.print ("This program creates grades for a class");
    // Ask user how many students are in the class
    System.out.print ("How many students are in the class?");
    Students = input.nextInt();
    // Tell user to input total number of points
    Points = input.nextInt();
    int[] klist = new int[<F11>
    Class Average =
    if (Grade >= 90); { {
    Grade = "A";}
    else if (Grade >= 80) {
    Grade = "B";}
    else if (Grade >= 70) {
    Grade = "C";}
    else if (Grade >= 60) {
    Grade = "D";}
    else if (Grade < 60); {
    Grade = "F";}

    } // end of main method
    } // end of class

  2. #2
    Solarsonic is offline Senior Member
    Join Date
    Mar 2011
    Posts
    261
    Rep Power
    4

    Default

    Copy and paste the exact errors that you receive.

  3. #3
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    392
    Rep Power
    4

    Default

    Also, edit your first post to put the code between code tags.

  4. #4
    jmjbreezin is offline Member
    Join Date
    May 2011
    Posts
    3
    Rep Power
    0

    Default

    Thanks for your reply...here it is (with errors)



    // This program creates a table of grades for a class

    import java.util.*;
    public class Class{ Grades
    { // This Program will create a table of grades for a class.
    public static void main(String[] args)
    {
    int Grade, Points, Students;
    double Percent;
    // User input three initials
    String initials = input.next();
    System.out.printf(String "Initials is %s Points is %d Percent is %f Grade is %c, Initials, Points, Percent, Grade);
    Scanner input = new Scanner(System.in);
    // Tell user what this program does
    System.out.print ("This program creates grades for a class");
    // Ask user how many students are in the class
    System.out.print ("How many students are in the class?");
    Students = input.nextInt();
    // Tell user to input total number of points
    Points = input.nextInt();
    int[] klist = new int[<F11>
    Class Average =
    if (Grade >= 90); { {
    Grade = "A";}
    else if (Grade >= 80) {
    Grade = "B";}
    else if (Grade >= 70) {
    Grade = "C";}
    else if (Grade >= 60) {
    Grade = "D";}
    else if (Grade < 60); {
    Grade = "F";}

    } // end of main method
    } // end of class





    **** HERE IS THE ERROR REPORT

    ClassGrades.java:43: 'else' without 'if'
    } else if (Points >= 80) {
    ^
    ClassGrades.java:52: reached end of file while parsing
    } // end of class
    ^

  5. #5
    jmjbreezin is offline Member
    Join Date
    May 2011
    Posts
    3
    Rep Power
    0

    Default

    Sorry for asking this, what do you mean by code tags?

  6. #6
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    392
    Rep Power
    4

    Default

    Put [ code] and [ /code] (without the spaces) at the start and end of your code. It preserves your indentations and makes the code much easier to read.

  7. #7
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    392
    Rep Power
    4

    Default

    Also, I think I've found your error: if (Grade >= 90); { { Why two {? Also, don't put ; after if, or the if does nothing.

    EDIT: Or at least one of the problems. I think you'll get some other errors once you fix that.
    Last edited by Toll; 05-09-2011 at 01:36 PM.

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Quote Originally Posted by jmjbreezin View Post
    Java Code:
    public class Class{ Grades
    Huh?

    db

Similar Threads

  1. keyTyped is it correct
    By aizen92 in forum New To Java
    Replies: 18
    Last Post: 04-03-2011, 01:47 PM
  2. Replies: 5
    Last Post: 06-08-2010, 04:22 PM
  3. Are my comments correct?
    By twiggy62 in forum New To Java
    Replies: 2
    Last Post: 02-08-2010, 05:34 AM
  4. Getting correct output
    By WarmRegards in forum New To Java
    Replies: 9
    Last Post: 11-01-2009, 04:41 PM
  5. Is this the correct Output?
    By Teny in forum New To Java
    Replies: 17
    Last Post: 04-13-2009, 12:52 PM

Tags for this Thread

Posting Permissions

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