Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Par {
- public static void main(String args[]){
- Scanner leia = new Scanner(System.in);
- int num;
- System.out.print("Entre com o numero: ");
- num = leia.nextInt();
- String par;
- //operador ternario
- /* if (num % 2 == 0) {
- par = "par\n";
- else {
- par = "impar\n";
- } */
- par = (num%2==0) ? "par\n" : "impar\n";
- System.out.printf("O numero eh: %s", par);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement