Advertisement
MasterGun

Untitled

May 9th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. class IConverter {
  5. public:
  6.     virtual double convertto(double value) = 0;
  7.     virtual double convertfrom(double value) = 0;
  8. };
  9. class Kconverter : public IConverter{
  10. public:
  11.     virtual double convertto(double degrees) override{
  12.         return degrees + 273.15;
  13.     }
  14.     virtual double convertfrom(double kelvin) override{
  15.         return kelvin - 273.25;
  16.     }
  17. };
  18. class FConverter : public IConverter {
  19. public:
  20.     virtual double convertto(double degrees) override{
  21.         return (degrees * 9/5)+32;
  22.     }
  23.     virtual double convertfrom(double far) override{
  24.         return far - (9/5)+32 ;
  25.     }
  26. };
  27. int main(){
  28.     setlocale(LC_ALL, "Russian");
  29.  
  30.     Kconverter k;
  31.     FConverter f;
  32.     cout << k.convertto(5) << endl;
  33.     cout << f.convertto(5) << endl;
  34.     cout << k.convertfrom(5) << endl;
  35.     cout << f.convertfrom(5) << endl;
  36.  
  37.  
  38.    
  39. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement