Guest User

Untitled

a guest
May 24th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main();
  7.  
  8. class Calculators;
  9.     {
  10.  
  11.     private:
  12.         long calculateLargeAnswer(){
  13.  
  14.             long h;
  15.             long j;
  16.             char a;
  17.             long answerL = h + j;
  18.  
  19.  
  20.  
  21.  
  22.  
  23.             cout << "The sum of your numbers is " << answerL << ". \n";
  24.             cout << "Continue calculations? (Y/N)";
  25.                 cin >> a;
  26.  
  27.             if (a == 'Y')
  28.                 main();
  29.             if (a == 'N')
  30.                 return 0;
  31.                 }
  32.  
  33.     public:
  34.         long calculateLarge(){
  35.  
  36.             long h;
  37.             long j;
  38.  
  39.  
  40.             cout << "Please enter a number. \n";
  41.                 cin >> h;
  42.  
  43.             cout << "Enter another number. \n";
  44.                 cin >> j;
  45.  
  46.             calculateLargeAnswer();
  47.             }
  48.  
  49.  
  50.  
  51.  
  52.  
  53.     private:
  54.         int calculateSmallAnswer(){
  55.  
  56.             int x;
  57.             int y;
  58.             char d;
  59.             int answer = x + y;
  60.  
  61.  
  62.  
  63.             cout << "The sum of your numbers is "  << answer << ". \n";
  64.             cout << "Would you like to continue calculations? (Y/N) \n";
  65.                 cin >> d;
  66.  
  67.             if(d == 'Y')
  68.                 main();
  69.  
  70.             if(d == 'N')
  71.                 return 0;
  72.                 }
  73.  
  74.  
  75.     public:
  76.         int calculateSmall(){
  77.  
  78.             int x;
  79.             int y;
  80.  
  81.  
  82.             cout << "Please enter a number. \n";
  83.                 cin >> x;
  84.  
  85.             cout << "Enter another number. \n";
  86.                 cin >> y;
  87.  
  88.  
  89.             calculateSmallAnswer();
  90.             }
  91.  
  92. }
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102. int main(){
  103.  
  104.      Calculators calcChoice;
  105.  
  106.  
  107.      int g;
  108.  
  109.      cout << "1. Large Calculation \n";
  110.      cout << "2. Small Calculation \n";
  111.         cin >> g;
  112.  
  113.      if (g == '1');
  114.          calcChoice.calculateLarge();
  115.  
  116.      if (g == '2');
  117.          calcChoice.calculateSmall();}
Add Comment
Please, Sign In to add comment