> The following program, FahrToCent.java, is suppose to request the user to input an integer for the temperature in Fahren

The following program, FahrToCent.java, is suppose to request the user to input an integer for the temperature in Fahren

Posted at: 2014-12-18 
when using ints 5/9 == zero

This works if you can only use ints:

import java.util.Scanner;

public class FahrToCent {

public static void main(String[] args) {

int fahr = 0;

int cent = 0;

Scanner input = new Scanner( System.in );

System.out.print("Temperature in Fahrenheit: ");

fahr = input.nextInt();

cent = (fahr - 32) * (5000/9) / 1000;

System.out.println("Temperature in Centigrades: " + cent);

}

}

The following program, FahrToCent.java, is supposed to request the user to input an integer for the temperature in Fahrenheit and print the temperature in Celsius degrees also as an integer according to the formula C = (F-32)(5/9).

import java.util.Scanner;

public class FahrToCent {

public static void main(String[] args) {

int fahr = 0;

int cent = 0;

Scanner input = new Scanner( System.in );

System.out.print("Temperature in Fahrenheit: ");

fahr = input.nextInt();

cent = (fahr - 32)*(5/9);

System.out.println("Temperature in Centigrades: " + cent);

}

}

Does the program work correctly? If not, improve the program without using double data types anywhere (because the intent of the program is to deal with temperatures only as integers without any higher precision).