Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using std::cin;
  4. using std::cout;
  5. using std::endl;
  6.  
  7. int main() {
  8.  
  9. double luku;
  10. char choice;
  11. char L = 'L';
  12. int l = 'l';
  13. double tulos;
  14. double tulos1;
  15. double tulos2;
  16. double tulos3;
  17.  
  18. cout << "Valitse luku. \n";
  19. cin >> luku;
  20. cout << "Valitse laskutoimitus (1=Neliojuuri 2=log 3=exp 4=tan L = Lopetus) \n";
  21. cin >> choice;
  22.  
  23. while (choice != 'L' && choice != 'l')
  24. {
  25. if (choice == '1')
  26. {
  27. tulos = sqrt(luku);
  28. cout << "Syottamasi luvun neliojuuri on " << tulos << endl;
  29. cout << "Valitse luku. \n";
  30. cin >> luku;
  31. cout << "Valitse laskutoimitus (1=Neliojuuri 2=log 3=exp 4=tan L = Lopetus) \n";
  32. cin >> choice;
  33. }
  34. else if (choice == '2')
  35. {
  36. tulos1 = log(luku);
  37. cout << "syottamasi luvu logaritmi on " << tulos1 << endl;
  38. cout << "Valitse luku. \n";
  39. cin >> luku;
  40. cout << "Valitse laskutoimitus (1=Neliojuuri 2=log 3=exp 4=tan L = Lopetus) \n";
  41. cin >> choice;
  42. }
  43. else if (choice == '3')
  44. {
  45. tulos2 = exp(luku);
  46. cout << "Syottamasi luvun eksponentti on " << tulos2 << endl;
  47. cout << "Valitse luku. \n";
  48. cin >> luku;
  49. cout << "Valitse laskutoimitus (1=Neliojuuri 2=log 3=exp 4=tan L = Lopetus) \n";
  50. cin >> choice;
  51. }
  52.  
  53. else if (choice == '4')
  54. {
  55. tulos3 = tan(luku);
  56. cout << "Syottamasi luvun tangentti on " << tulos3 << endl;
  57. cout << "Valitse luku. \n";
  58. cin >> luku;
  59. cout << "Valitse laskutoimitus (1=Neliojuuri 2=log 3=exp 4=tan L = Lopetus) \n";
  60. cin >> choice;
  61. }
  62.  
  63. }
  64. cout << "Ei laskemista, selkee! \n";
  65. system("pause");
  66. return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement