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 4 of 4

Thread: Java Program ferinheight to celsius Table

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java Program ferinheight to celsius Table

    I am creating a table that will convert ferinheight to celsius. I do not get any errors but the celsius column only prints out 0.0, while the ferinheight table prints from 90-110, which I want. Im not sure why the equation is not printing out. Any help is greatly appreciated thank you!






    import java.util.Scanner;

    public class Lab5{
    public static void main(String [] args){
    Scanner scan = new Scanner(System.in);


    System.out.println("What is your first name?");
    String name= scan.nextLine();

    System.out.println("What is your last name?");
    String name2= scan.nextLine();

    String fullname = name +" "+ name2;


    System.out.println("What country are you from?");
    String country= scan.nextLine();

    System.out.println(" ");



    System.out.println("Dear, " + fullname);

    System.out.println(" ");

    System.out.println("Welcome to the sunny city of El Paso. We realize that in " + country + ", ");

    System.out.println("you are not accustomed to degrees Fahrenheit (F). To help you, ");

    System.out.println("we are providing you with conversion to Celsius (C):");




    int start = 90;
    final int end = 110;

    System.out.println(" ");
    System.out.println("F \t C");

    System.out.println("--------------");

    while (start <= end)
    {
    double celsius = (5/9) * (start - 32);

    System.out.println(start + "\t" + celsius);

    start++;
    }




    System.out.println(" ");
    System.out.println("Enjoy our beautiful city!");
    }
    }


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 166 Times in 157 Posts

    Default Re: Java Program ferinheight to celsius Table

    Integer division versus floating point division.
    System.out.println(5/9);
    Improving the world one idiot at a time!

  3. #3
    Junior Member
    Join Date
    Oct 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java Program ferinheight to celsius Table

    Im sorry, I dont understand. That code interferes with the equation to convert the temperatures. Could you explain in more detail? Thanks in advance!!

  4. #4
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 166 Times in 157 Posts

    Default Re: Java Program ferinheight to celsius Table

    I'm suggesting you stick that line of code into a test program and run it to see what result it gives.
    Improving the world one idiot at a time!

Similar Threads

  1. Celsius to fahrenheit vice versa
    By Onlyname in forum What's Wrong With My Code?
    Replies: 5
    Last Post: September 16th, 2013, 11:39 PM
  2. [SOLVED] Converting Fahrenheit to Celsius
    By remedys in forum What's Wrong With My Code?
    Replies: 5
    Last Post: August 23rd, 2012, 03:26 AM
  3. [SOLVED] Trouble with fahrenheit to celsius conversion.
    By HaHom Tsa Pfnuma in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 27th, 2012, 09:50 AM
  4. Temperature Table Celsius and Fahrenheit
    By Krodfish in forum Loops & Control Statements
    Replies: 2
    Last Post: February 2nd, 2012, 09:06 PM
  5. 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