-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSumAverage.java
More file actions
23 lines (22 loc) · 824 Bytes
/
SumAverage.java
File metadata and controls
23 lines (22 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.Scanner;
public class SumAverage
{
public static void main(String args[])
{
Scanner reader = new Scanner(System.in);
System.out.println("Enter first number: ");
int n1 = reader.nextInt();
System.out.println("Enter second number: ");
int n2 = reader.nextInt();
System.out.println("Enter third number: ");
int n3 = reader.nextInt();
System.out.println("Enter fourth number: ");
int n4 = reader.nextInt();
System.out.println("Enter fifth number: ");
int n5 = reader.nextInt();
int sum = n1 + n2 + n3 + n4 + n5;
float avg = (n1 + n2 + n3 + n4 + n5)/5;
System.out.println("Sum of " + n1 + ", " + n2 + ", " + n3 + ", " + n4 + ", " + n5 + " = " + sum);
System.out.println("Average of " + n1 + ", " + n2 + ", " + n3 + ", " + n4 + ", " + n5 + " = " + avg);
}
}