Sanady

Mesiace

Feb 16th, 2018
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.00 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 cviko1;
  7.  
  8. import java.util.Scanner;
  9. import java.util.*;
  10. /**
  11.  *
  12.  * @author xrener
  13.  */
  14. public class Cviko1 {
  15.  
  16.     /**
  17.      * @param args the command line arguments
  18.      */
  19.    
  20.    
  21.    
  22.    
  23.     public static void main(String[] args) {
  24.         /*int cislo1 = 55;
  25.         int cislo2 = 45;
  26.         if(cislo1 < cislo2)
  27.         {
  28.             System.out.println("Cislo2 je vacsie ako cislo 1");
  29.         }
  30.         else if(cislo2 < cislo1)
  31.         {
  32.             System.out.println("Cislo1 je vacsie ako cislo2");
  33.         }
  34.         System.out.println("Hello World");*/
  35.        
  36.         /*Scanner input = new Scanner(System.in);
  37.        
  38.         int cislo1;
  39.         int cislo2;
  40.        
  41.         System.out.println("Zadajte jedno cislo:");
  42.         cislo1 = input.nextInt();
  43.        
  44.         System.out.println("Zadajte druhe cislo:");
  45.         cislo2 = input.nextInt();
  46.        
  47.         if(cislo1 < cislo2)
  48.         {
  49.             System.out.println("Cislo "+cislo2+" je vacsie ako "+cislo1+" !");
  50.         }
  51.         else if(cislo2 < cislo1)
  52.         {
  53.             System.out.println("Cislo "+ cislo1 +" je vacsie ako "+ cislo2 +" !");
  54.         }*/
  55.        
  56.         /*int den;
  57.  
  58.        
  59.         Scanner input = new Scanner(System.in);
  60.        
  61.         System.out.println("Zadajte den narodenia:");
  62.         den = input.nextInt();
  63.        
  64.         System.out.println("Zadajte mesiac narodenia:");
  65.         mesiac = input.nextInt();*/
  66.        
  67.         /*switch(mesiac)
  68.         {
  69.             case 1:
  70.                 if(den >= 1 || den <= 20)
  71.                 {
  72.                     System.out.println("Horoskop: Kozorozec");
  73.                 }
  74.                 else if(den >= 21 || den <= 31)
  75.                 {
  76.                     System.out.println("Horoskop: Vodnar");
  77.                 }
  78.                 break;
  79.                
  80.             case 2:
  81.                
  82.            
  83.         }*/
  84.         Scanner input = new Scanner(System.in);
  85.        
  86.         int m;
  87.                
  88.         System.out.println("Zadajte mesiac: ");
  89.         m = input.nextInt();
  90.        
  91.         ArrayList<String> mesiac = new ArrayList<String>();
  92.        
  93.         mesiac.add(null);
  94.         mesiac.add(1, "Januar");
  95.         mesiac.add(2, "Februar");
  96.         mesiac.add(3, "Marec");
  97.         mesiac.add(4, "April");
  98.         mesiac.add(5, "Maj");
  99.         mesiac.add(6, "Jun");
  100.         mesiac.add(7, "Jul");
  101.         mesiac.add(8, "August");
  102.         mesiac.add(9, "September");
  103.         mesiac.add(10, "Oktober");
  104.         mesiac.add(11, "November");
  105.         mesiac.add(12, "December");
  106.        
  107.         try{
  108.             System.out.println("Vypis mesiace "+mesiac.get(m));
  109.         }catch(IndexOutOfBoundsException error){
  110.             System.out.println("Neznamy mesiac!");
  111.         }
  112.        
  113.        
  114.        
  115.     }
  116.    
  117. }
Advertisement
Add Comment
Please, Sign In to add comment