Advertisement
PiotrSzewczyk

Zadanie 3/wskaźniki

Nov 2nd, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 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.  
  28. int main()
  29. {
  30.  
  31.     Rachunek pierwszy;
  32.     pierwszy.nazwa_sklepu="Comfort";
  33.     pierwszy.podatek=23;
  34.     pierwszy.cena=2000;
  35.     pierwszy.nazwa_produktu="Szafka";
  36.  
  37.     pierwszy.wyswietl();
  38.  
  39.     Rachunek obiekt;
  40.     obiekt.nazwa_sklepu="Lidl";
  41.     obiekt.podatek=23;
  42.     obiekt.cena=3000;
  43.     obiekt.nazwa_produktu="Monitor";
  44.     obiekt.oblicz();
  45.     return 0;
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement