• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java help

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I'm reading this right, this might work
 
Eric Johns
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic