Archived

This topic is now archived and is closed to further replies.

fooman_69

[java] School prob. This is the best place to ask Im Sure!

Recommended Posts

fooman_69    174
Im having a prob with an assignment in my begginner Java class at school, and I figured this would be a great place to ask! The program reads in a file of measurements, the first line of this file is the unit of measurement used. The user then enters a unit to convert the measurements to, and then the a new file with the new converted measurements is written in a location specified by the user. The problem I have is when deciding what conversion to use. What is the best way to determine what the user has entered (conversion unit) compared to the first line read (the initial unit of measure read)? I know my teacher will rip my head off if I put 20+ if statements, which I agree with. There has to be a better way.

Share this post


Link to post
Share on other sites
blackone    456
Tip: When converting between 2 unknown units, choose 1 unit as your standard unit. Then convert input->standard->output, easier than listing all of the conversion factors between the different units.
(Example: meter is your standard unit, file lists measurements in miles and user chooses kilometers for the display. You don''t have to know how to convert meter to kilometers, only how to convert to and from meter: miles -> meters -> kilometers)

***
For Java games and Java related resources, go to http://www.javaengines.dk
***

Share this post


Link to post
Share on other sites