Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. // 1 task
  2. #include <iostream>
  3.  
  4. class Coiner {
  5.     int nominal, count;
  6.  
  7. public:
  8.     Coiner() {};
  9.  
  10.     Coiner(int nominal, int count) {
  11.         this->nominal = nominal;
  12.         this->count = count;
  13.     }
  14.  
  15.     void print() {
  16.         std::cout << "<Coiner nominal: " << this->nominal << " count: " << this->count << ">";
  17.     }
  18.  
  19.     int sum() {
  20.         return this->nominal * this->count;
  21.     }
  22. };
  23.  
  24. int main() {
  25.     int n, c;
  26.     std::cout << "Введите номинал монеты: ";
  27.     std::cin >> n;
  28.     std::cout << "Введите количество монет: ";
  29.     std::cin >> c;
  30.  
  31.     Coiner coiner(n, c);
  32.     std::cout << "Строка с информацией о родительском объекте:" << std::endl;
  33.     coiner.print();
  34.  
  35.     std::cout << std::endl << "Сумма монет: " << coiner.sum() << std::endl;
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement