File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java help

 
Eric Johns
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this program that takes user input and searches a data file for cars that meet the users preferences, now if their are cars that match. The output, "Cars that match your requirements with at least 80% fit:, needs to display how many cars that would be and I can't seem to figure out how I could go about doing this. below I have what I have come up with I have added another if statement and another var called totalcars. is their a way to take the cars that work for the boolean statement and register them into a number?
thanks Eric



(Marilyn added code tags)
[ September 27, 2003: Message edited by: Marilyn de Queiroz ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I'm reading this right, this might work
 
Eric Johns
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah I think that would work, but the counter has to been in the statment "Cars that match your requirements with at least 80% fit", so it should say something like Example, "2 Cars that match your requirements with at least 80% fit:" and the problem I'm having is that statement can only be displayed once per starting run of the loop and since the guts of the calculations are in a for loop how can I get a total number of cars that are going to get printed when the loop running on car at a time.
I can't seem to think of anything
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This should do what you want (this is aircode - so expect typos, missing semi-colons etc). You might also have to convert some of the carData info to String.

[ September 28, 2003: Message edited by: Michael Dunn ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic