Table of Contents
Assignment: Calculate Sum and Average of Three Numbers
Assignment: Calculate Sum and Average of Three Numbers
Problem Statement:
Write a Java program that prompts the user to enter three numbers, calculates their sum, and then computes the average. The program should display both the sum and the average as output.
Requirements:
- Prompt the user to input three numbers.
- Calculate the sum of these three numbers.
- Compute the average of the three numbers.
- Display the sum and average with appropriate messages.
Example Output:
- Input:
10,20,30- Sum:
60 - Average:
20.0
- Sum:
- Input:
15,25,35- Sum:
75 - Average:
25.0
- Sum:
Hints:
- Use the
Scannerclass for input. - Remember to cast the sum to
doubleif you want the average as a floating-point number. - You can calculate the average by dividing the sum by 3.
If you require additional resources, consider purchasing: ICSE Computer Applications Class 10 – Previous Year Question Papers & Solutions (Java Fundamentals)