Guest User

Untitled

a guest
Oct 22nd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. int secondary(int argc, char* argv[])
  4. {
  5.     std::cout << "calculator" << std::endl; \
  6.     std::cout << "Vill du räkna 'division', 'multiplikation', 'addition' eller 'subtraktion'?"; \
  7. }
  8. #define Func(str, check, print, op) \
  9.     if(a, b != int or double)
  10.     {
  11.         std::cout << "Can only calculate INT" << std::endl; \
  12.     }
  13.     if(str == check) \
  14.     { \
  15.         std::cout << "Skriv vad som skall " << print << std::endl; \
  16.         std::cin >> a >> b; \
  17.         if (check == "division") \
  18.         { \
  19.         std::cout << a op b << std::endl; \
  20.         std::cout << a op b * 100 + "%"; \
  21.         else \
  22.         std::cout << a op b << std::endl; \
  23.         }
  24.     }
  25.  
  26. int main(int argc, char* argv[])
  27. {
  28.    
  29.     double a, b;
  30.     std::string c;
  31.     std::cin >> c;
  32.     {
  33.         Func(c, "multiplikation", "multipliceras", *)
  34.         else
  35.         Func(c, "addition", "adderas", +)
  36.         else
  37.         Func(c, "subtraktion", "subtraheras", -)
  38.         else
  39.         Func(c, "division", "divideras", /)
  40.     }
  41.    
  42.     system("PAUSE");
  43.     return 0;
  44. }
  45. #undef Func
Add Comment
Please, Sign In to add comment