Advertisement
GraionDilach

Untitled

Sep 12th, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 2.15 KB | None | 0 0
  1.  
  2. public class ThroughTheHaywireCalledAsJava {
  3.    
  4.     public static void main(String[] args) {
  5.    
  6.     //1-es
  7.     String Example = "Adios muchachos!";
  8.    
  9.     System.out.println(Example);
  10.  
  11.     //2-es
  12.     int InputNumber =5;
  13.    
  14.     if (InputNumber == 1 || InputNumber == 2 || InputNumber ==12)
  15.     {
  16.         System.out.println("Tél");
  17.     }
  18.    
  19.     if (InputNumber == 3 || InputNumber == 4 || InputNumber == 5)
  20.     {
  21.         System.out.println("Tavasz");
  22.     }
  23.    
  24.     if (InputNumber == 6 || InputNumber == 7 || InputNumber == 8)
  25.     {
  26.         System.out.println("Nyár");
  27.     }
  28.    
  29.     if (InputNumber == 9 || InputNumber == 10 || InputNumber == 11)
  30.     {
  31.         System.out.println("Ősz");
  32.     }
  33.  
  34.    
  35.     switch (InputNumber)
  36.     {
  37.         case 12:
  38.         case 1:
  39.         case 2: System.out.println("Tél");
  40.             break;
  41.         case 3:
  42.         case 4:
  43.         case 5: System.out.println("Tavasz");
  44.             break;
  45.         case 6:
  46.         case 7:
  47.         case 8: System.out.println("Nyár");
  48.             break;
  49.         case 9:
  50.         case 10:
  51.         case 11: System.out.println("Ősz");
  52.             break;
  53.         default:
  54.             break;
  55.     }
  56.    
  57.     //3-as
  58.     for (int i = 1; i < 11; i++){
  59.         for (int j = 1; j <= i; j++){
  60.             System.out.print(i*j + "\t");
  61.             }
  62.         System.out.println();
  63.         }
  64.    
  65.     //5-ös
  66.     int[] ExampleLine = {1245, 8525, 12, 45, 36954,
  67.             457, 336, 96, 558, 10};
  68.     int smallest = ExampleLine[0];
  69.     for (int i = 1; i < 10; i++){
  70.         if (smallest> ExampleLine[i]){
  71.             smallest = ExampleLine[i];
  72.         }
  73.     }
  74.    
  75.     System.out.println ("A legkisebb: " + smallest);
  76.    
  77.     int largest = ExampleLine[0];
  78.     for (int i = 1; i < 10; i++){
  79.         if (largest < ExampleLine[i]){
  80.             largest = ExampleLine[i];
  81.         }
  82.     }
  83.    
  84.     System.out.println ("A legnagyobb: " + largest);
  85.    
  86.     for (int i = 0; i < 9; i++){
  87.         for (int j = i; j <10; j++){
  88.             if (ExampleLine[i] > ExampleLine [j]){
  89.                 int temp = ExampleLine[i];
  90.                 ExampleLine[i] = ExampleLine[j];
  91.                 ExampleLine[j] = temp;
  92.             }
  93.         }
  94.     }
  95.    
  96.     System.out.print("A tömb elemei:\t");
  97.     for (int i = 0; i < 10; i++){
  98.         System.out.print(ExampleLine[i] + "\t");
  99.     }
  100.     System.out.println ();
  101.    
  102.     //6-os
  103.     int[] Radii = { 4, 5, 8};
  104.    
  105.     double pi = 3.14;
  106.    
  107.     for (int i = 0; i < 3; i++){
  108.         System.out.println ("A kör sugara: " + Radii[i] + ", területe: " + Radii[i]*pi*Radii[i]);
  109.     }
  110.     }
  111.    
  112.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement