Advertisement
Guest User

Untitled

a guest
Mar 24th, 2013
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. package Pierwszy_program_obiektowy;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Firma {
  6.  
  7. public static void main(String[] args) {
  8.  
  9. System.out.println("Proszę podać ilu pracowników chcesz dodać do bazy: ");
  10. Scanner in = new Scanner(System.in);
  11. int ilosc = in.nextInt();
  12. Pracownik[] em = new Pracownik[ilosc];
  13.  
  14. for (int i=0; i<em.length; i++){
  15. em[i] = new Pracownik();
  16. System.out.println("Proszę podać imię " +(i+1) +" pracownika: ");
  17. em[i].imie = in.nextLine();
  18. System.out.println("Proszę podać nazwisko " +(i+1) +" pracownika: ");
  19. em[i].nazwisko = in.nextLine();
  20. System.out.println("Proszę podać wiek " +(i+1) +" pracownika: ");
  21. em[i].wiek = in.nextInt();
  22. }
  23.  
  24. System.out.println("Pracownicy firmy to: ");
  25.  
  26. for (int i=0; i<em.length; i++)
  27. System.out.println(em[i].imie+ " "+ em[i].nazwisko+ ", "+ "lat "+em[i].wiek);
  28.  
  29.  
  30.  
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement