-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMedia.java
More file actions
31 lines (22 loc) · 771 Bytes
/
Media.java
File metadata and controls
31 lines (22 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.Scanner;
/*
2. Create a program to receive 3 integer values from the user and show their average (which may not be an integer).
*/
public class Media {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int num1 = 0;
int num2 = 0;
int num3 = 0;
double media = 0.0;
System.out.println("Digite um número: ");
num1 = scanner.nextInt();
System.out.println("Digite um número: ");
num2 = scanner.nextInt();
System.out.println("Digite um número: ");
num3 = scanner.nextInt();
media = (num1 + num2 + num3)/3.0;
System.out.println("A média dos valores inseridos é: " + media);
scanner.close();
}
}