![]() |
Programming Question Part 2
Replace < with <
|
http://download.oracle.com/javase/1....l/Scanner.html
This has a better explanation of how to use a Scanner than I would write. |
Yes. You should make a Scanner on listings.txt and use it to read in all of the property types. Something like:
while (scanner.hasNextLine()) propertyType.add(scanner.nextLine()); |
Oh, sorry, I misread the OP.
So, initially the Set propertyType will be empty. You don't know the different property types before you read listings.txt. So instead it looks like this: Code: Code:
int property; int agent; double price; String type; while (scanner.hasNextLine()) { property = scanner.nextInt(); type = scanner.nextString(); price = scanner.nextDouble(); agent = scanner.nextInt(); // do what you need to do with these values } |
I'm really at a point where I just don't know what the **** to do. It's not even covered in the ****ing book or course but I'm being asked to do it. What kind of ****ing piece of **** course is this? I'm so ****ing tired of this ****ing ****. There's no ****ing reason for this ****.
Here's my code: while (console.hasNextLine()) { property = console.nextInt(); type = console.next(); price = console.nextDouble(); agent = console.nextInt(); propertyType.add(type); } I don't understand how the **** this thing knows to disregard stuff and keep on moving and only entering in the things it needs. There's no ****ing explanation anywhere for this ****. I've ****ing had it. |
Have you though about choosing some other profession? If you can't wrap your head around some algorithms, maybe you're better off forging steel?
|
Right now after I put in my input file when running it it then asks for the output file which it shouldn't be doing. If I take out the while statement it runs fine again, so I'm doing something wrong with the while statement.
|
dp
|
idMap.put(agent, price);
This line is wrong. Not in the sense of you are calling a function wrong, etc. but in the sense that you algorithm should do something different. Imagine, for a moment, that you were doing this on paper and were creating (and updating) a table of agent/total price pairs as you read in the input file. If you saw agent ID 007, what would you do? Then do that in code. |
There is, of course, also get().
|
You can't do this in one method call.
|
All times are GMT +1. The time now is 11:06 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0 PL2