Advertisement
caiofersousa

Untitled

Oct 21st, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package javaapplication2;
  7.  
  8. import java.util.Scanner;
  9.  
  10. /**
  11.  *
  12.  * @author caio
  13.  */
  14. public class JavaApplication2 {
  15.  
  16.     /**
  17.      * @param args the command line arguments
  18.      */
  19.     public static void main(String[] args) {
  20.         int num = 0;
  21.         String opc;
  22.        Scanner sc = new Scanner(System.in);
  23.                   int contaux =0;
  24.  
  25.         System.out.println("Digite um númmero: ");
  26.        num = sc.nextInt();
  27.         System.out.println("Digite se deseja exibir os pares ou os impares: (p = par i = impar)");
  28.         opc = sc.next();
  29.        
  30.         for(int cont=1; cont<=num; cont ++){
  31.              if(contaux%5==0){
  32.                 System.out.println("");
  33.              }    
  34.             if((cont%2==0)&&(opc.equals("p"))){
  35.                     System.out.print(cont+" \t  ");
  36.                                 contaux++;
  37.  
  38.                    
  39.             } else if((cont%2==1)&&(opc.equals("i"))){
  40.                    System.out.print(cont+" \t  ");
  41.                                contaux++;
  42.  
  43.             }
  44.            
  45.            
  46.  
  47.      
  48.  
  49.         }
  50.     }
  51.    
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement