Results 1 to 10 of 15
Thread: Help with Java work...again.
-
- Join Date
- 11-26-06
- Location
- Anywhere you want to be.
- Posts
- 3,946
- Post Thanks / Like
- Blog Entries
- 1
10-27-09, 10:20 PM #1Help 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(); } } }
-
10-27-09, 11:25 PM #2
Re: Help with Java work...again.
Originally Posted by i8pptuakamonstercam
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
-
- Join Date
- 11-26-06
- Location
- Anywhere you want to be.
- Posts
- 3,946
- Post Thanks / Like
- Blog Entries
- 1
10-27-09, 11:53 PM #3Re: Help with Java work...again.
-
-
-
- Join Date
- 11-26-06
- Location
- Anywhere you want to be.
- Posts
- 3,946
- Post Thanks / Like
- Blog Entries
- 1
10-28-09, 12:00 AM #6Re: 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.^^
-
-
-
10-28-09, 12:18 AM #9
Re: Help with Java work...again.
Originally Posted by Imisnew2
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
-
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks