50.7k views
3 votes
The following code does not work as intended. It is meant to input two test grades and return the average in decimal format: int test1 = scan.nextInt(); int test2 = scan.nextInt(); double average = (test1 + test2 )/2; System.out.println("Answer: " + average);

User Lafeber
by
6.5k points

1 Answer

4 votes

Answer:

To return average in Decimal we will use float datatype instead of double.

Step-by-step explanation:

int test1 = scan.nextInt();

int test2 = scan.nextInt();

float average = (test1 + test2 )/2;

System.out.println("Answer: " + average);

User Stonean
by
7.7k points