Guest User

Untitled

a guest
Feb 25th, 2015
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. double firstX;
  2. double firstY;
  3. double secondX;
  4. double secondY;
  5. double kphase1;
  6. double kphase2;
  7. double kVal;
  8. double kValMultiply;
  9. double mVal;
  10. double substractY;
  11. double substractK;
  12. double yVal;
  13. double addY;
  14. double addK;
  15. string userInput;
  16.  
  17.  
  18. do
  19. {
  20. cout << "K-value calculator by Alexander Ensani TE14B" << endl;
  21. cout << "" << endl;
  22.  
  23. cout << "Type in the first coordinate pair" << endl;
  24. cout << "" << endl;
  25.  
  26. cout << "Enter the value of the first X: ";
  27. cin >> firstX;
  28. cout << "Enter the value of the first Y: ";
  29. cin >> firstY;
  30. cout << "" << endl;
  31.  
  32. cout << "Type in the second coordinate pair" << endl;
  33. cout << "" << endl;
  34.  
  35. cout << "Enter the value of the second X: ";
  36. cin >> secondX;
  37. cout << "Enter the value of the second Y: ";
  38. cin >> secondY;
  39. cout << "" << endl;
  40.  
  41. kphase1 = secondY - firstY;
  42. kphase2 = secondX - firstX;
  43. kVal = kphase1 / kphase2;
  44.  
  45. cout << "The first coordinate pair is: (" << firstX << "," << firstY << ")" << endl;
  46. cout << "The second coordinate pair is: (" << secondX << "," << secondY << ")" << endl;
  47. cout << " " << endl;
  48.  
  49. cout << "I will calculate the value of K with the following formula: ";
  50. cout << secondY << " - " << firstY << " / " << secondX << " - " << firstX << endl;
  51. cout << "" << endl;
  52.  
  53. cout << "The value of K is: " << kVal << endl;
  54.  
  55. cout << "Would you like to know what the value of M is? Type Y or N" << endl;
  56. cin >> userInput;
  57. cout << " " << endl;
  58.  
  59. if (userInput == "y" || userInput == "Y") {
  60.  
  61. cout << "I will try to solve the following equation: ";
  62. cout << firstY << " = " << kVal << " * " << firstX << " + M" << endl;
  63. cout << "" << endl;
  64.  
  65. kValMultiply = kVal * firstX;
  66.  
  67. substractK = kValMultiply - kValMultiply;
  68. substractY = firstY - kValMultiply;
  69.  
  70. addK = kValMultiply + kValMultiply;
  71. addY = firstY + kValMultiply;
  72.  
  73. if (kValMultiply > 0) {
  74.  
  75. cout << "The equation results: ";
  76. cout << substractY << " = " << substractK << " + M" << endl;
  77. cout << "" << endl;
  78. cout << "The value of M is: " << substractY << endl;
  79.  
  80. }
  81.  
  82. if (kValMultiply < 0) {
  83.  
  84. cout << "The equation results: ";
  85. cout << addY << " = " << addK << " + M" << endl;
  86. cout << "" << endl;
  87. cout << "The value of M is: " << addY << endl;
  88.  
  89. }
  90. }
  91.  
  92. else if (userInput == "n" || userInput == "N") {
  93. cout << " " << endl;
  94. cout << "Okay, we will leave it like this!" << endl;
  95. cout << "" << endl;
  96. }
  97. else {
  98.  
  99. cout << "Invalid input, please type Y (Yes) or N (No)." << endl;
  100.  
  101. }
  102. } while (userInput != "n");
Advertisement
Add Comment
Please, Sign In to add comment