Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package kontrolno2;
- import java.util.Scanner;
- /**
- *
- * @author Gaby
- */
- public class Kontrolno2 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.println("Въведи брой работници");
- int numEmp = sc.nextInt();
- int arrayEmp [] = new int [numEmp];
- int max = 0;
- while (numEmp < 0){
- System.out.println("Въведи положителен брой работници");
- numEmp = sc.nextInt();
- }
- for (int i = 0; i < arrayEmp.length; i++) {
- System.out.println("Въведи възрастта на работник № " + (i + 1));
- arrayEmp [i] = sc.nextInt();
- while (arrayEmp [i] < 18 || arrayEmp [i] > 65){
- System.out.println("Въведи отново възрастта на работник № " + (i + 1));
- arrayEmp [i] = sc.nextInt();
- }
- if(arrayEmp [i] > max){
- max = arrayEmp [i];
- }
- }
- System.out.print("Работниците над 25 са с номера\t");
- for (int i = 0; i < arrayEmp.length; i++){
- if (arrayEmp [i] > 25){
- System.out.print(i + 1);
- System.out.print("\t");
- }
- }
- System.out.println();
- System.out.println("Най-възрастният работник е на възраст " + max);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement