I am trying to prevent java from rounding the result of user-input values. here is the code,
import java.util.Scanner;
public class questions {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
System.out.print("enter two integers");
int firstNumber = in.nextInt();
int secondNumber = in.nextInt();
System.out.print("the average is = ");
System.out.println((firstNumber + secondNumber)/2);
// end
}
}
|For example, when I put 5 and 6 as inputs,it outputs 5 instead of 5.50