Reading text file and counting the number of words, integers, and floats.
Need this thread deleted. No longer need help.
Re: Reading text file and counting the number of words, integers, and floats.
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.
Re: Reading text file and counting the number of words, integers, and floats.
The number of integers in the file is 64 and the number of words is 29 the number of floats is 3
>
Re: Reading text file and counting the number of words, integers, and floats.
Are the count like this:
wrong vs correct
64 vs 129 ints
29 vs 30 words
3 vs 68 floats
0 vs 6 invalid
Re: Reading text file and counting the number of words, integers, and floats.
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.
Re: Reading text file and counting the number of words, integers, and floats.
Quote:
Originally Posted by
Norm
Are the count like this:
wrong vs correct
64 vs 129 ints
29 vs 30 words
3 vs 68 floats
0 vs 6 invalid
Yeah! That's my problem. I'm still trying to play around with my code but still not getting correct results.
Re: Reading text file and counting the number of words, integers, and floats.
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.
Re: Reading text file and counting the number of words, integers, and floats.
Quote:
Originally Posted by
Norm
Are the count like this:
wrong vs correct
64 vs 129 ints
29 vs 30 words
3 vs 68 floats
0 vs 6 invalid
Sorry my mistake, it is suppose to be
Re: Reading text file and counting the number of words, integers, and floats.
Quote:
Originally Posted by
Norm
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.
I have done everything. Been spending multiple hours figuring ways to debug it and have it print the correct amount for each one. Do you think my methods are not checking the integers, floats, and words correctly?
Re: Reading text file and counting the number of words, integers, and floats.
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.
Re: Reading text file and counting the number of words, integers, and floats.
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...
Re: Reading text file and counting the number of words, integers, and floats.
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.