Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Temperature Table Celsius and Fahrenheit

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Temperature Table Celsius and Fahrenheit

    Hello everyone I need help building the following below, can someone please please help?

    I need to Create a program that takes three inputs from the command line arguments. The inputs will need to be a starting and ending temperature and a step to increment by. For example, if the inputs were 1 5 1 the program would print a table with Fahrenheit temperatures (and their Celsius equivalent) for the temperatures 1, 2, 3, 4, 5. If the inputs were 2 10 2 the Farenheit temperatures would be: 2, 4, 6, 8, 10.
    The program will convert temperatures from Fahrenheit to Celsius. The program will start at the starting temperature that was entered as a command line argument. Then the program will loop through all the Farenheit temperatures (incrementing by step on each loop iteration) until the program reaches the ending temperature that was specified as the second command line argument.
    Your program should print out a Header line and then print out the Farenheit temperature and the corresponding Celsuis temperature on one line. For example:
    Farenheit Celsius
    212.0 100.0
    The Farenheit temperature in your calculation can be an integer data type, but the Celsius temperature will need to be a floating point data type to ensure that the decimal digits are accurate.


    package temperature.table;


    public class TemperatureTable {

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
    // TODO code application logic here
    int far, cel;
    int lower, upper, step;
    lower = 0;
    upper = 200;
    step = 15;
    far = lower;

    System.out.print("Fahrenheit\tCelsius");


    while ( far <= upper )
    {
    cel = 5 * (far -32) /9;
    System.out.println(far);

    System.out.println (" ");

    System.out.println (cel);
    far = far + step;
    }
    }
    }
    This is my first time developing a Java system, I have never done one before. I've been trying to do this all week and this is as far as I got. Please help me.
    Last edited by Krodfish; February 2nd, 2012 at 08:58 PM. Reason: Forgot to add the code the first time my bad...again I've never built a Java application before, so this is tough.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,156
    My Mood
    Hungover
    Thanks
    141
    Thanked 595 Times in 510 Posts

    Default Re: Temperature Table Celsius and Fahrenheit

    What have you tried? Where are you stuck? Recommended reading: How to Program (stuck on homework? READ THIS BEFORE POSTING)
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Temperature Table Celsius and Fahrenheit

    I forgot the code earlier...can u please help. I have absolutely no experience in Java.

    I need to put the values underneath System.out.print("Fahrenheit\tCelsius"); on the output.

    Also, is what I did anywhere near what the problem is asking?

Similar Threads

  1. Conversions Between Celsius and Fahrenheit
    By baueml01 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: October 9th, 2011, 07:49 PM
  2. (Beginner) Hopelessly lost on Temperature converting (C to F, F to C)
    By skw4712 in forum What's Wrong With My Code?
    Replies: 13
    Last Post: July 18th, 2011, 07:34 PM
  3. Object Table
    By aussiemcgr in forum AWT / Java Swing
    Replies: 3
    Last Post: June 2nd, 2011, 01:16 PM
  4. NEED HELP WITH TEMPERATURE
    By Dracer in forum AWT / Java Swing
    Replies: 5
    Last Post: December 11th, 2010, 02:12 PM
  5. Converting temperature program
    By ixjaybeexi in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 20th, 2009, 07:27 PM

Tags for this Thread