Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   java Mathematical decimal point error (http://www.go4expert.com/forums/java-mathematical-decimal-error-t26625/)

an2new 5Sep2011 08:57

java Mathematical decimal point error
Java math error.
I got a prompt asking to covert from Fahrenheit to Celsius and it seem to compiled right and everything but the mathematical solution does not have the right decimal point. I tried everything I know please help. Example if you cal 72 F = 22.22 C...I got 72 F = 22.0 C. Here the program.

import java.util.Scanner;

public class Handout1Project5
    public static void main(String[] args)
        Scanner scannerObject = new Scanner(System.in);
        System.out.println("Hello out there");
        System.out.println("I will converts degrees Fahrenheit to Celsius for you.");
        System.out.println("Enter a temperature in degrees Fahrenheit:  ");
        int user_Input;
        double degrees_Output;
        user_Input = scannerObject.nextInt();
        System.out.println("You entered:" + user_Input);
        degrees_Output = (((user_Input - 32) * 5) / 9);
        System.out.println(user_Input + " degrees Fahrenheit" + " = " + degrees_Output + " Celsius");
        System.out.printf("%d degrees Fahrenheit = %3.2f degrees Celsius %n", user_Input, degrees_Output);

an2new 5Sep2011 09:26

Re: java Mathematical decimal point error
nvm thank you I have found out the solution. Please delete this thread.

All times are GMT +5.5. The time now is 04:16.