Advertisement
DawidKubiak

Sprawdzian Zad.3

Oct 28th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class pracownik
  6. {
  7.     public:
  8.     string imie;
  9.     string nazwisko;
  10.     int wiek;
  11.     string plec;
  12.  
  13.     void wyswietl()
  14.     {
  15.         cout<<imie<<endl;
  16.         cout<<nazwisko<<endl;
  17.         cout<<wiek<<endl;
  18.         cout<<plec<<endl;
  19.     }
  20.     void dopisz()
  21.     {
  22.         cout<<"imie:"<<endl;
  23.         cin>>imie;
  24.         cout<<"nazwisko:"<<endl;
  25.         cin>>nazwisko;
  26.         cout<<"wiek:"<<endl;
  27.         cin>>wiek;
  28.         cout<<"plec"<<endl;
  29.         cin>>plec;
  30.  
  31.         if (wiek <= 19)
  32.         {
  33.             cout<<"Wiek jest mniejszy niż 19"<<endl;
  34.         }
  35.     };
  36. };
  37. int main()
  38. {
  39.     pracownik P1;
  40.     P1.imie="Dawid";
  41.     P1.nazwisko="Kubiak";
  42.     P1.wiek=19;
  43.     P1.plec='m';
  44.  
  45.     P1.wyswietl();
  46.     pracownik P2;
  47.     P2.dopisz();
  48.    return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement