Jump to content
  • Advertisement

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!

This topic is 5407 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
put all of your variables into an array, and once you need the conversion rate, call the array and use the right operation the you need

Share this post


Link to post
Share on other sites
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!