Challenge: Average of Three

Lab Java Beginner 10 points

Read three whole numbers and print their average with exactly 2 decimals.

Input

Three whole numbers.

Output

Average: <value> with 2 decimals, e.g. Average: 2.33.

Example

Input

1 2 4

Output

Average: 2.33
Sample input available Sample output available
Editor
Java

Hints

Divide by 3.0, not 3, so you don't lose the decimals.

printf("%.2f", x) prints 2 decimals.

Solution explanation

Dividing by 3.0 makes the answer a double. %.2f rounds it to 2 decimals.

Show solution
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        double avg = (a + b + c) / 3.0;
        System.out.printf("Average: %.2f%n", avg);
    }
}
Output
Answer
HOME LABS COMMUNITY DASHBOARD