Advertisement
G_Burlakova

Задача_Работници

Nov 25th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 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.  
  7. package kontrolno2;
  8. import java.util.Scanner;
  9. /**
  10.  *
  11.  * @author Gaby
  12.  */
  13. public class Kontrolno2 {
  14.  
  15.     /**
  16.      * @param args the command line arguments
  17.      */
  18.     public static void main(String[] args) {
  19.         Scanner sc = new Scanner(System.in);
  20.         System.out.println("Въведи брой работници");
  21.         int numEmp = sc.nextInt();
  22.         int arrayEmp [] = new int [numEmp];
  23.         int max = 0;
  24.         while (numEmp < 0){
  25.             System.out.println("Въведи положителен брой работници");
  26.             numEmp = sc.nextInt();
  27.         }
  28.         for (int i = 0; i < arrayEmp.length; i++) {
  29.             System.out.println("Въведи възрастта на работник № " + (i + 1));
  30.             arrayEmp [i] = sc.nextInt();
  31.             while (arrayEmp [i] < 18 || arrayEmp [i] > 65){
  32.                 System.out.println("Въведи  отново възрастта на работник № " + (i + 1));
  33.                 arrayEmp [i] = sc.nextInt();
  34.             }
  35.             if(arrayEmp [i] > max){
  36.                 max = arrayEmp [i];
  37.             }
  38.         }
  39.         System.out.print("Работниците над 25 са с номера\t");
  40.         for (int i = 0; i < arrayEmp.length; i++){
  41.             if (arrayEmp [i] > 25){
  42.                 System.out.print(i + 1);
  43.                 System.out.print("\t");
  44.             }
  45.         }
  46.         System.out.println();
  47.         System.out.println("Най-възрастният работник е на възраст " + max);
  48.     }
  49.    
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement