-
Notifications
You must be signed in to change notification settings - Fork 1
/
12.java
29 lines (18 loc) · 829 Bytes
/
12.java
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
/*******************************************************************************
* 12) Escreva um programa que leia um número inteiro e exiba o seu módulo.
* O módulo de um número x é:
* x se x é maior ou igual a zero
* x * (-1) se x é menor que zero
*******************************************************************************/
import java.util.Scanner;
public class Exercicio {
public static void main(String[] args) {
Scanner entrada = new Scanner(System.in);
int Numero,ModuloNumero;
System.out.print("Módulo de Número\n\n");
System.out.print("Digite um número inteiro: ");
Numero = entrada.nextInt();
ModuloNumero = (Numero < 0)? ModuloNumero = Numero*(-1):Numero;
System.out.print("O módulo do número é "+ModuloNumero+"\n");
}
}