Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Help with Java work...again.

  1. Registered TeamPlayer i8pptuakamonstercam's Avatar
    Join Date
    11-26-06
    Location
    Anywhere you want to be.
    Posts
    3,946
    Post Thanks / Like
    Blog Entries
    1
    Stat Links

    Help with Java work...again.
    #1

    Help with Java work...again.

    //The purpose of this program is to compute average values, minimum values, and
    //maximum values for the GPAs (grade point averages) of college students.
    //Certain quantities are computed according to the living groups in which
    //the students reside, and other quantities are overall values.

    I would post the whole thing but you do have to read a little. Here is a link to assignment.
    http://cs.okstate.edu/cs1113/programs/program05.html

    The problem I am getting is the,
    ';'expected.

    It occurs on this line of code
    =========================================
    double overallMinGPA 0.0, overallMaxGPA = 0.0;
    =========================================

    The funny thing is that when I go through my code everything is correct in its format, so I have decided to let a fresh pair of eyes look at it to see any obvious mistakes.

    FYI it is not completely done, but I think it still should compile.
    Code:
    //The purpose of this program is to compute average values, minimum values, and
    //maximum values for the GPAs (grade point averages) of college students. 
    //Certain quantities are computed according to the living groups in which
    //the students reside, and other quantities are overall values.
    
    import java.util.Scanner;
    import java.text.DecimalFormat;
    public class Gpa
    {
      public static void main (String[] args)
      {
        final boolean DEBUG = true;
        final String SENTINEL = "EndOfGroup";
        Scanner scan = new Scanner(System.in);
        DecimalFormat fmt = new DecimalFormat("0.00");
        double minGPA = 0.0, maxGPA = 4.0;
        int numGroup = 0, numTotal = 0;
        
        String livingGroup = "";
        while(scan.hasNext())
        {
          livingGroup = scan.nextLine();
          System.out.println("Living group: " + livingGroup);
          
          double stuGPA = 0.0, groupGPA = 0.0, overallGPA = 0.0; 
          double maxGroupGPA = 0.0, minGroupGPA = 0.0;
          double overallMinGPA 0.0, overallMaxGPA = 0.0;
          String stuName = "";
          stuName = scan.next();
          While(!stuName.equals(SENTINEL))
          {
            if(scan.hasNextDouble())
            {
              stuGPA = scan.nextDouble();
              if(stuGPA < minGPA || stuGPA > maxGPA)
              {
                System.out.println("GPA not within range.");
                System.exit(0);
              }
            }
            else
            {
              System.out.println("Error: " + strBad);
              System.exit(0);
            }
            
            System.out.println("Student: " + stuName + " " +
            " GPA = " + stuGPA);
            
            numGroup++;
            numTotal++;
            if(DEBUG)
            {
              System.out.println("DEBUG:");
              System.out.println("Number in group = " + numGroup + " " +
              "GPA sum in group = " + groupGPA);
              System.out.println("Total number = " + numTotal + " " +
              "GPA sum overall = " + overallGPA);
              System.out.println("Minimum GPA in group = " + minGroupGPA + 
              " "+ "Maximum GPA in group = " + maxGroupGPA);
              System.out.println("Overall minimum GPA = " + overallMinGPA +
              " " + "Overall maximum GPA = " + overallMaxGPA);
            }
            
            System.out.println("Average GPA for this group = " + 
            ((overallGPA) / (numGroup)));
            System.out.println("Minimum GPA for this group = " + minGroupGPA);
            System.out.println("Maximum GPA for this group = " + maxGroupGPA);
            
            stuName = scan.next();
          }
          numGroup = 0;
          scan.nextLine();
        }
      }
    }

  2. Administrator Kanati's Avatar
    Join Date
    05-15-08
    Location
    Pekin, Illinois, United States
    Posts
    17,724
    Post Thanks / Like
    Stat Links

    Help with Java work...again. Help with Java work...again. Help with Java work...again. Help with Java work...again. Help with Java work...again. Help with Java work...again.
    #2

    Re: Help with Java work...again.

    Quote Originally Posted by i8pptuakamonstercam
    //The purpose of this program is to compute average values, minimum values, and
    //maximum values for the GPAs (grade point averages) of college students.
    //Certain quantities are computed according to the living groups in which
    //the students reside, and other quantities are overall values.

    I would post the whole thing but you do have to read a little. Here is a link to assignment.
    http://cs.okstate.edu/cs1113/programs/program05.html

    The problem I am getting is the,
    ';'expected.

    It occurs on this line of code
    =========================================
    double overallMinGPA 0.0, overallMaxGPA = 0.0;
    =========================================
    Heh... Not sure you want me to point this one out to you........

    Take a nice long look at that first variable declaration and tell me what you are missing.








    =========================================
    double overallMinGPA 0.0, overallMaxGPA = 0.0;
    =========================================

    Should Be:
    =========================================
    double overallMinGPA = 0.0, overallMaxGPA = 0.0;
    =========================================

    Krakkens and shit. stop tempting them.
    -- Bigdog

  3. Registered TeamPlayer i8pptuakamonstercam's Avatar
    Join Date
    11-26-06
    Location
    Anywhere you want to be.
    Posts
    3,946
    Post Thanks / Like
    Blog Entries
    1
    Stat Links

    Help with Java work...again.
    #3

    Re: Help with Java work...again.

    Ok ok you win, that was a really dumb mistatke.
    Now I am getting the same error on another line.

    [img width=700 height=437]http://img101.imageshack.us/img101/1608/codes.png[/img]
    if this code is too hard to see click on thumbnail below.

    Click on "full size" for best view.

  4. Administrator Kanati's Avatar
    Join Date
    05-15-08
    Location
    Pekin, Illinois, United States
    Posts
    17,724
    Post Thanks / Like
    Stat Links

    Help with Java work...again. Help with Java work...again. Help with Java work...again. Help with Java work...again. Help with Java work...again. Help with Java work...again.
    #4

    Re: Help with Java work...again.

    <cough cough> java is case sensitive <cough>

    While != while

    Krakkens and shit. stop tempting them.
    -- Bigdog

  5. Registered TeamPlayer Too Much Damage's Avatar
    Join Date
    08-31-07
    Location
    Ft Worth, Tx
    Posts
    5,391
    Post Thanks / Like
    Stat Links

    Help with Java work...again. Help with Java work...again. Help with Java work...again. Help with Java work...again. Help with Java work...again. Help with Java work...again. Help with Java work...again.
    Gamer IDs

    Gamertag: T00 MUCH D4M4G3 Steam ID: TooMuchDamage Too Much Damage's Originid: TooMuchDamage
    #5

    Re: Help with Java work...again.

    Will you stop cheating?

  6. Registered TeamPlayer i8pptuakamonstercam's Avatar
    Join Date
    11-26-06
    Location
    Anywhere you want to be.
    Posts
    3,946
    Post Thanks / Like
    Blog Entries
    1
    Stat Links

    Help with Java work...again.
    #6

    Re: Help with Java work...again.

    Ok man I'm not cheating, Im just asking for some new eyes to look at my code to see things that I am obviously not seeing.

    If I were cheating I would ask, "can someone show me how to do this" or something to that nature.

    I just want to get all these little trivial mistakes out of the way.


    P.S.Thanks for the help guys, I'm done with this crap.^^

  7. Administrator Kanati's Avatar
    Join Date
    05-15-08
    Location
    Pekin, Illinois, United States
    Posts
    17,724
    Post Thanks / Like
    Stat Links

    Help with Java work...again. Help with Java work...again. Help with Java work...again. Help with Java work...again. Help with Java work...again. Help with Java work...again.
    #7

    Re: Help with Java work...again.

    The worst part...

    I don't program java. Never liked it and I've never written one program in java. I'm a .NET man myself.

    Krakkens and shit. stop tempting them.
    -- Bigdog

  8. Registered TeamPlayer Imisnew2's Avatar
    Join Date
    01-19-08
    Posts
    4,588
    Post Thanks / Like
    Blog Entries
    9
    #8

    Re: Help with Java work...again.

    Quote Originally Posted by Kanati8869
    The worst part...

    I don't program java. Never liked it and I've never written one program in java. I'm a .NET man myself.
    Java is so much better than VB and C# though ...

  9. Administrator Kanati's Avatar
    Join Date
    05-15-08
    Location
    Pekin, Illinois, United States
    Posts
    17,724
    Post Thanks / Like
    Stat Links

    Help with Java work...again. Help with Java work...again. Help with Java work...again. Help with Java work...again. Help with Java work...again. Help with Java work...again.
    #9

    Re: Help with Java work...again.

    Quote Originally Posted by Imisnew2
    Quote Originally Posted by Kanati8869
    The worst part...

    I don't program java. Never liked it and I've never written one program in java. I'm a .NET man myself.
    Java is so much better than VB and C# though ...
    Don't MAKE me crawl all up in this computer here and kick some ass.

    I've always said though that those that don't like .NET have never really dug into it and used it for any length of time. I hated it when I started. And I've seen many other converts over the years.

    Krakkens and shit. stop tempting them.
    -- Bigdog

  10. Registered TeamPlayer Imisnew2's Avatar
    Join Date
    01-19-08
    Posts
    4,588
    Post Thanks / Like
    Blog Entries
    9
    #10

    Re: Help with Java work...again.

    I prefer C++ :P

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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