I am new to Java. I wrote this easy program but for some reason even though I am using the conversion specifier %f for float, the quotient ( division calculation ) is returning the result in the command window as 0.000000. Why is this not calculating correctly? Below is the question I wrote the program to answer.
/* 2.15 (Arithmetic) Write an application that asks the user to enter two integers, obtains them from the user and prints their sum, product, difference and quotient (division). Use the techniques shown in Fig. 2.7. */
import java.util.Scanner;
public class Main
{
public static void main ( String [] args )
{
Scanner input = new Scanner (System.in);
int a;
int b;
int sum;
int product;
int difference;
float quotient;
System.out.println( "Enter the first integer: ");
a = input.nextInt();
System.out.println( "Enter the second integer: ");
b = input.nextInt();
sum = a + b;
System.out.printf( "The sum is %d.%n", sum );
product = a * b;
System.out.printf( "The product is %d.%n", product );
difference = a - b;
System.out.printf ( "The difference is %d.%n", difference );
quotient = a / b;
System.out.printf ( "The quotient is %f.%n", quotient );
}
}