Need this thread deleted. No longer need help.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Need this thread deleted. No longer need help.
Last edited by Jsmooth; April 12th, 2012 at 07:14 PM.
Can you post the program's output and also post what the output should be.
For testing I'd use as small a file as possible so it is easy to see which numbers are wrong.
If you don't understand my answer, don't ignore it, ask a question.
The number of integers in the file is 64 and the number of words is 29 the number of floats is 3
>
Last edited by Jsmooth; April 12th, 2012 at 07:14 PM.
Are the count like this:
wrong vs correct
64 vs 129 ints
29 vs 30 words
3 vs 68 floats
0 vs 6 invalid
If you don't understand my answer, don't ignore it, ask a question.
I told you, "The number of integers in the file is 64 and the number of words is 29 the number of floats is 3"
But this is wrong so my code isn't correctly counting them right. Which is what I can't figure out.
Try debugging the program by adding printlns to the code that track the execution and show the results of each test line by line and value by value.
Print out each line as it is read, then print out the counts after that line is scanned and the counts made.
If you don't understand my answer, don't ignore it, ask a question.
Make a small input file, add printlns as I described to print out the results as each line is read.
Execute the program and look at the output and see if it is correct. If not then add more printlns to the methods where the count is not correct to see why that method is not doing what you want.
If that file has no errors, replace the input file with another small file with few lines and run it again. You need a small test file that will be counted incorrectly. Then you can work on the methods that are not working correctly.
If you don't understand my answer, don't ignore it, ask a question.
I have been doing that. I have now got it to get the correct number of words. The number of integers and floats is what I can't get nor the invalid ones. Can you actually look at my code and see what you would do? I'm really stressing over this...
Did you print out some of the integers and floats that were counted incorrectly?
Can you post them and the debug print outs from the methods that tested them?
Write a simple testing program that uses one of the integers that the method fails to detect and call the method with it. Print out everything that the method does to see where the logic is wrong.
I don't see where your code counts the number of invalids.
If you don't understand my answer, don't ignore it, ask a question.