Help with java homework....

Status
Not open for further replies.
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
 
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.
 
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.
 
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..
 
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.
 
Status
Not open for further replies.
Back