LOGO
General Discussion Undecided where to post - do it here.

Reply to Thread New Thread
Old 10-23-2010, 10:38 PM   #1
PemiaGefe

Join Date
Oct 2005
Posts
527
Senior Member
Default Programming Question Part 2
Replace < with <
PemiaGefe is offline


Old 10-24-2010, 03:12 AM   #2
enencephoth

Join Date
Oct 2005
Posts
434
Senior Member
Default
http://download.oracle.com/javase/1....l/Scanner.html

This has a better explanation of how to use a Scanner than I would write.
enencephoth is offline


Old 10-24-2010, 04:16 AM   #3
Amirmsheesk

Join Date
Oct 2005
Posts
530
Senior Member
Default
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());
Amirmsheesk is offline


Old 10-24-2010, 04:22 AM   #4
EasyLOAD

Join Date
Oct 2005
Posts
567
Senior Member
Default
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 }

If you were reading through listings.txt normally (in notepad or whatever), and trying to construct an agentreport.txt file according to their spec, what would you do? Then code that.
EasyLOAD is offline


Old 10-24-2010, 06:31 AM   #5
Si8jy8HN

Join Date
Oct 2005
Posts
485
Senior Member
Default
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.
Si8jy8HN is offline


Old 10-24-2010, 10:40 PM   #6
jisee

Join Date
Oct 2005
Posts
389
Senior Member
Default
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?
jisee is offline


Old 10-24-2010, 11:02 PM   #7
WrigleyMike

Join Date
Oct 2005
Posts
398
Senior Member
Default
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.
WrigleyMike is offline


Old 10-25-2010, 12:15 AM   #8
Infellgedq

Join Date
Oct 2005
Posts
478
Senior Member
Default
dp
Infellgedq is offline


Old 10-25-2010, 12:50 AM   #9
tiereenny

Join Date
Oct 2005
Posts
391
Senior Member
Default
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.
tiereenny is offline


Old 10-25-2010, 02:47 AM   #10
67Irralphaisa

Join Date
Oct 2005
Posts
665
Senior Member
Default
There is, of course, also get().
67Irralphaisa is offline


Old 10-25-2010, 03:10 AM   #11
JohnMaltczevitch

Join Date
Oct 2005
Posts
530
Senior Member
Default
You can't do this in one method call.
JohnMaltczevitch is offline



Reply to Thread New Thread

« Previous Thread | Next Thread »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

All times are GMT +1. The time now is 01:00 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.6.0 PL2
Design & Developed by Amodity.com
Copyright© Amodity