Welcome to the TechSpot OpenBoards. Please read the FAQ if you have any questions. Login to participate.

Go Back   TechSpot OpenBoards > OS & Software > Misc. Software & Utilities

Help with java homework....

Reply
Bookmark / Share this page
Thread Tools
  #1  
Old 11-14-2007
Newcomer, in training
 
Member since: Oct 2007, 5 posts
Help with java homework....

Can someone please look at this, I'm sure I'm just missing something really easy. Something is wrong with my Method. I'm brand new to java, so don't laugh.

I realize you can't see everything...put maybe someone can spot the problem real quick.


Code:
public class SpacelySprockets
{

	public static void main(String[] args) //Main Program
	{  //Start Main


		int partNumber=0;
		int quantity=0;
		int part1Total=0;
		int part2Total=0;
		int part3Total=0;
		int part4Total=0;
		int part5Total=0;

		Keyboard kbd;
		kbd = new Keyboard ();

		InputFile sprockets;
		sprockets = new InputFile ("E:\\MaxSync\\School\\SLCC\\CIS 1030\\Spacely Sprockets\\sprockets.txt");

		while (!sprockets.eof())
		{   //Start Loop

			partNumber=sprockets.readInt ();
			quantity=sprockets.readInt ();


			switch (partNumber)
			{
				case 1:		part1Total = part1Total + quantity;
							break;
				case 2:		part2Total = part2Total + quantity;
							break;
				case 3:		part3Total = part3Total + quantity;
							break;
				case 4:		part4Total = part4Total + quantity;
							break;
				case 5:		part5Total = part5Total + quantity;
							break;
				default:	System.out.println ("The file has unknown part numbers ltstd");
			}


		}   //End Loop

		detailLine (part1Total, 1);
		detailLine (part2Total, 2);
		detailLine (part3Total, 3);
		detailLine (part4Total, 4);
		detailLine (part5Total, 5);


	}  //End Main

	public static void detailLine (int partTotal, int partNumber);
	{
		OutputFile summaryReport;
		summaryReport = new OutputFile ("E:\\MaxSync\\School\\SLCC\\CIS 1030\\Spacely Sprockets\\summaryReport.txt");

		summaryReport.writeWord (partTotal, partNumber);
		summaryReport.writeEOL();
		summaryReport.close();

	}


} //End Class

Last edited by Didou; 11-14-2007 at 07:30 AM.
Reply With Quote
  #2  
Old 11-14-2007
Nodsu's Avatar
TS Special Forces
 
Location: Estonia
Member since: Feb 2002, 9,430 posts
System specs
What exactly is wrong?

It is very hard to read code written by someone else. Tell us what it is supposed to do and what really happens.
Reply With Quote
You can remove this banner by registering, join the TS Community for free.
  #3  
Old 11-14-2007
Newcomer, in training
 
Member since: Oct 2007, 5 posts
Sorry, I should have given more information.

The program is supposed to read a text file that contains information like below....

1 99
2 88
3 77
4 66
5 55
1 10
2 35
5 50
3 60

It supposed to add up the numbers on the right, corresponding with the numbers on the left and right that information to a file. For example there are 105 "5"s and 123 "2"s.

So the new file should look like this

1 109
2 123
3 137
4 66
5 105

However,

When I compile my program...I get this error.


E:\MaxSync\School\SLCC\CIS 1030\Spacely Sprockets\SpacelySprockets.java:56: missing method body, or declare abstract
public static void detailLine (int partTotal, int partNumber);
^
E:\MaxSync\School\SLCC\CIS 1030\Spacely Sprockets\SpacelySprockets.java:61: cannot find symbol
symbol : variable partTotal
location: class SpacelySprockets
summaryReport.writeWord (partTotal, partNumber);
^
E:\MaxSync\School\SLCC\CIS 1030\Spacely Sprockets\SpacelySprockets.java:61: cannot find symbol
symbol : variable partNumber
location: class SpacelySprockets
summaryReport.writeWord (partTotal, partNumber);
^
3 errors

Tool completed with exit code 1

I've also tried using writeWord, writeInt, and writeString.

Last edited by howard_hopkinso; 11-14-2007 at 06:48 PM. Reason: POSTS MERGED: PLEASE USE THE EDIT BUTTON, RATHER THAN MAKING A NEW POST WHEN THERE ARE NO OTHER REPLIES INBETWEEN, THANKS.
Reply With Quote
  #4  
Old 11-15-2007
Nodsu's Avatar
TS Special Forces
 
Location: Estonia
Member since: Feb 2002, 9,430 posts
System specs
Remove the semicolon from the end of line 56 (public static void detailLine...).

You seem to be using some course-specific classes (Keyboard, InputFile, OutputFile), so I can't verify the correctness of the program..
Reply With Quote
  #5  
Old 11-15-2007
Newcomer, in training
 
Member since: Oct 2007, 5 posts
wow, I feel stupid. I can't believe I spent so much time over one semicolon. I knew it would be something simple.

I got the programing running now. Thanks for your help.
Reply With Quote
Reply
Thread Tools

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Can some one please help me on my homework for geometry Grr_San_jose_Ca The Meeting 'spot' 7 09-29-2006 05:30 AM
Java help Ghaleon Other Hardware 0 01-01-2006 04:02 AM
Need some homework help AtK SpAdE Storage & Networking 3 11-19-2004 10:56 AM
java thadanman2k1 Misc. Software & Utilities 2 03-07-2004 01:45 PM


All times are GMT -4. The time now is 08:07 AM.