Results 1 to 4 of 4
  1. #1
    niloufar is offline Member
    Join Date
    Sep 2012
    Posts
    26
    Rep Power
    0

    Question 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;
    	}
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default 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.

    ** This space for rent **

  3. #3
    niloufar is offline Member
    Join Date
    Sep 2012
    Posts
    26
    Rep Power
    0

    Default Re: get three inputs at one time, then perform the conversions on the three inputs!

    Quote Originally Posted by Tolls View Post
    What does "get all three inputs at one time" mean?
    i don't know! this was a reply from my prof. that if i do this way is better ! what do you think? can you give me an idea ?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default 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.

    ** This space for rent **

Similar Threads

  1. Replies: 26
    Last Post: 12-03-2013, 02:55 PM
  2. Same inputs, different outputs.
    By werner291 in forum New To Java
    Replies: 4
    Last Post: 12-15-2011, 07:36 PM
  3. Someone plz help... how to block inputs
    By waklo99 in forum New To Java
    Replies: 4
    Last Post: 03-15-2010, 06:44 AM
  4. How to create this if many inputs?
    By sarahannel123 in forum New To Java
    Replies: 3
    Last Post: 05-18-2008, 04:22 PM
  5. Date Inputs
    By hiranya in forum AWT / Swing
    Replies: 3
    Last Post: 11-06-2007, 05:11 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •