Results 1 to 4 of 4
- 09-06-2012, 06:43 AM #1
Member
- Join Date
- Sep 2012
- Posts
- 26
- Rep Power
- 0
get three inputs at one time, then perform the conversions on the three inputs!
Anybody can tell me how I get all three inputs at one time, then perform the conversions on the three inputs , and then display the results to the user!
here is my codes:
Java Code:import java.util.Scanner; /** * Convert temperture, distance, and weight. */ public class UnitConversionTool { // Declarations public static final double METER_PER_FEET = 0.3048; // a constant value for the decimal value used in the meters public static final double KILOGRAM_PER_POUND = 0.4536; // a constant value for the decimal value used in the kilograms public static int Fahrenheit, Distance, Weight; // variable values public static void main (String[] args ) { Scanner input = new Scanner(System.in); System.out.println("\nAuthor: "); System.out.println("Project 1 – Unit Conversion Tool"); // Get User inputs System.out.print("\nEnter a Fahrenheit temperature: "); Fahrenheit = input.nextInt(); // Gets input from the keyboard System.out.print("Enter a distance in feet: "); Distance = input.nextInt(); System.out.print("Enter a weight in pounds: "); Weight = input.nextInt(); // perform the calculations double Celsius = FahrenheitToCelsius(Fahrenheit); // invoke FahrenheitToCelsius method double Meters = (Distance * METER_PER_FEET ); double Kilograms = (Weight * KILOGRAM_PER_POUND); // Display result to the user System.out.println("\n"+Fahrenheit +" Fahrenheit is " +Celsius + " Celsius"); System.out.println(Distance +" Distance is "+ Meters+ " Meters"); System.out.println(Weight + " Weight is "+ Kilograms+ " Kilograms"); input.close(); // Close Scanner } /** * Calculates Fahrenheit To Celsius method * @param temp the Fahrenheit tempurture * @return the tempurture */ public static int FahrenheitToCelsius(int Fahrenheit){ int Celsius = (Fahrenheit - 32 )*5/9; return Celsius; } }
- 09-06-2012, 09:47 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: get three inputs at one time, then perform the conversions on the three inputs!
What does "get all three inputs at one time" mean?
Please do not ask for code as refusal often offends.
- 09-06-2012, 04:48 PM #3
Member
- Join Date
- Sep 2012
- Posts
- 26
- Rep Power
- 0
- 09-06-2012, 05:30 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: get three inputs at one time, then perform the conversions on the three inputs!
I really don't understand what they're meaning either I'm afraid.
The only thing I would say about your current set up is you are taking in all three things then providing answers.
I would take in the fahrenheit value and then give the answer before asking for the distance, and so on.
Which might be what they're meaning.Please do not ask for code as refusal often offends.
Similar Threads
-
Same inputs, different outputs.
By werner291 in forum New To JavaReplies: 4Last Post: 12-15-2011, 07:36 PM -
Someone plz help... how to block inputs
By waklo99 in forum New To JavaReplies: 4Last Post: 03-15-2010, 06:44 AM -
inputs numbers then outputs how many time a particular number appears
By koji_kun in forum New To JavaReplies: 23Last Post: 12-22-2009, 08:33 PM -
How to create this if many inputs?
By sarahannel123 in forum New To JavaReplies: 3Last Post: 05-18-2008, 04:22 PM -
Date Inputs
By hiranya in forum AWT / SwingReplies: 3Last Post: 11-06-2007, 05:11 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks