Advertisement
PiotrSzewczyk

Zadanie 4/wskaźniki

Nov 2nd, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.53 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. class Rachunek
  5.     {
  6.         public:
  7.         string nazwa_sklepu;
  8.         float podatek;
  9.         float cena;
  10.         string nazwa_produktu;
  11.  
  12.             void wyswietl()
  13.             {cout<<nazwa_sklepu<<endl;
  14.             cout<<podatek<<endl;
  15.             cout<<cena<<endl;
  16.             cout<<nazwa_produktu<<endl;
  17.                 cout<<endl;}
  18.             void oblicz() {
  19.                 int brutto;
  20.                 brutto=cena+(cena*podatek)/100;
  21.                 if (brutto<100)
  22.                     cout<<"Produkt zwolniony z vatu"<<endl;
  23.                 else
  24.                 cout<<brutto<<endl;
  25.             }
  26.  
  27.             Rachunek();
  28.             void konstruktor()
  29.             {
  30.  
  31.         nazwa_sklepu="Biedronka";
  32.         podatek=23;
  33.         cena=215;
  34.         nazwa_produktu="Klawiatura mechaniczna";
  35.                 cout<<"Konstruktor"<<endl;
  36.                 cout<<nazwa_sklepu<<endl;
  37.             cout<<podatek<<endl;
  38.             cout<<cena<<endl;
  39.             cout<<nazwa_produktu<<endl;
  40.                 cout<<endl;
  41.             }
  42.     };
  43.   Rachunek::Rachunek()
  44.     {
  45.  
  46.         konstruktor();
  47.  
  48.     }
  49. int main()
  50. {
  51.  
  52.     Rachunek pierwszy;
  53.     pierwszy.nazwa_sklepu="Comfort";
  54.     pierwszy.podatek=23;
  55.     pierwszy.cena=2000;
  56.     pierwszy.nazwa_produktu="Szafka";
  57.  
  58.     pierwszy.wyswietl();
  59.  
  60.     Rachunek obiekt;
  61.     obiekt.nazwa_sklepu="Lidl";
  62.     obiekt.podatek=23;
  63.     obiekt.cena=3000;
  64.     obiekt.nazwa_produktu="Monitor";
  65.     obiekt.oblicz();
  66.  
  67.  
  68.  
  69.     return 0;
  70. }
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement