Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-10-2007, 11:41 PM
Member
 
Join Date: Jul 2007
Posts: 2
mattvgt is on a distinguished road
help with java program
I'm getting errors while compiling this. Can someone point me in the right direction?

Code:
import java.util.Scanner; public class MaleFemaleGPA { static Scanner inFile = new Scanner(new FileReader(GPAdata.dat)); public static void main(String[] args) { char maleTotal, femaleTotal; int maleCount, femaleCount; double maleAverage, femaleAverage; if (inFile.next.charAt(0) = m) { maleTotal += inFile.nextDouble(); maleCount++; } else { femaleTotal += inFile.nextDouble(); femaleCount++; } maleAverage = maleTotal / maleCount; femaleAverage = femaleTotal / femaleCount; System.out.println("Average GPA for male students is " + maleAverage); System.out.println("Average GPA for female students is " + femaleAverage); inFile.close(); } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-12-2007, 04:03 PM
Member
 
Join Date: Jul 2007
Posts: 44
simon is on a distinguished road
can you explain what do you do with the code? and what is the problem exactly?
so I can test it and help you
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-12-2007, 06:34 PM
Member
 
Join Date: Jul 2007
Posts: 2
mattvgt is on a distinguished road
I have a file that is in the format:

m 2.92
f 2.60
f 2.62
m 4.0
etc...

The program is supposed to get the average of all the m's and f's. The m is for Male the f is for Female. The number beside of each m or f is the GPA. So it needs to get the average GPA for all male students and all female students.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-14-2007, 05:57 PM
Member
 
Join Date: Jul 2007
Posts: 36
boy22 is on a distinguished road
You have to define maleTotal, femaleTotal as real or double; maleCount, femaleCount as integer and then initialized them
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute an External Program through Java program Java Tip java.io 0 04-04-2008 03:40 PM
New to Java Program jvasilj1 New To Java 1 02-05-2008 08:22 AM
How to execute an External Program through Java program JavaBean Java Tips 0 10-04-2007 10:33 PM
help with simple java program leonard New To Java 3 07-30-2007 10:40 AM
java program nehasahu New To Java 5 07-12-2007 12:05 PM


All times are GMT +3. The time now is 10:21 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org