Advertisement
Jonas_3k

AtividadeMesCorrespondente

Sep 17th, 2022
1,199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class AtividadeMesCorrespondente {
  4.     public static void main(String[] args) {
  5.         var teclado = new Scanner(System.in);
  6.         try{
  7.             System.out.print("Digite o numero do mes: ");
  8.             var numeroMes = Integer.parseInt(teclado.nextLine());
  9.             System.out.println(String.format("O mes escolhido e: %s ",Mes.values()[numeroMes-1]));
  10.         }catch(Exception e){
  11.             System.out.println("Ocorreu um erro: "+e.getMessage());
  12.         }finally{ teclado.close(); }
  13.     }
  14.  
  15. }
  16.  
  17. enum Mes {
  18.  
  19.     JANEIRO,
  20.     FEVEREIRO,
  21.     MARCO,
  22.     ABRIL,
  23.     MAIO,
  24.     JUNHO,
  25.     JULHO,
  26.     AGOSTO,
  27.     SETEMBRO,
  28.     OUTUBRO,
  29.     NOVEMBRO,
  30.     DEZEMBRO;
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement