Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double firstX;
- double firstY;
- double secondX;
- double secondY;
- double kphase1;
- double kphase2;
- double kVal;
- double kValMultiply;
- double mVal;
- double substractY;
- double substractK;
- double yVal;
- double addY;
- double addK;
- string userInput;
- do
- {
- cout << "K-value calculator by Alexander Ensani TE14B" << endl;
- cout << "" << endl;
- cout << "Type in the first coordinate pair" << endl;
- cout << "" << endl;
- cout << "Enter the value of the first X: ";
- cin >> firstX;
- cout << "Enter the value of the first Y: ";
- cin >> firstY;
- cout << "" << endl;
- cout << "Type in the second coordinate pair" << endl;
- cout << "" << endl;
- cout << "Enter the value of the second X: ";
- cin >> secondX;
- cout << "Enter the value of the second Y: ";
- cin >> secondY;
- cout << "" << endl;
- kphase1 = secondY - firstY;
- kphase2 = secondX - firstX;
- kVal = kphase1 / kphase2;
- cout << "The first coordinate pair is: (" << firstX << "," << firstY << ")" << endl;
- cout << "The second coordinate pair is: (" << secondX << "," << secondY << ")" << endl;
- cout << " " << endl;
- cout << "I will calculate the value of K with the following formula: ";
- cout << secondY << " - " << firstY << " / " << secondX << " - " << firstX << endl;
- cout << "" << endl;
- cout << "The value of K is: " << kVal << endl;
- cout << "Would you like to know what the value of M is? Type Y or N" << endl;
- cin >> userInput;
- cout << " " << endl;
- if (userInput == "y" || userInput == "Y") {
- cout << "I will try to solve the following equation: ";
- cout << firstY << " = " << kVal << " * " << firstX << " + M" << endl;
- cout << "" << endl;
- kValMultiply = kVal * firstX;
- substractK = kValMultiply - kValMultiply;
- substractY = firstY - kValMultiply;
- addK = kValMultiply + kValMultiply;
- addY = firstY + kValMultiply;
- if (kValMultiply > 0) {
- cout << "The equation results: ";
- cout << substractY << " = " << substractK << " + M" << endl;
- cout << "" << endl;
- cout << "The value of M is: " << substractY << endl;
- }
- if (kValMultiply < 0) {
- cout << "The equation results: ";
- cout << addY << " = " << addK << " + M" << endl;
- cout << "" << endl;
- cout << "The value of M is: " << addY << endl;
- }
- }
- else if (userInput == "n" || userInput == "N") {
- cout << " " << endl;
- cout << "Okay, we will leave it like this!" << endl;
- cout << "" << endl;
- }
- else {
- cout << "Invalid input, please type Y (Yes) or N (No)." << endl;
- }
- } while (userInput != "n");
Advertisement
Add Comment
Please, Sign In to add comment