Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Build a command-line C++ application that allows user to calculate and display t

ID: 3902672 • Letter: B

Question

Build a command-line C++ application that allows user to calculate and display the distance between two points. The coordinates of the points for A and B will be entered by the user. The distance formula is a variant of the Pythagorean Theorem that you used back in geometry class. Ex: d=sqrt[(x2-x1)^2+(y2-y1)^2]. (All code must be written using the C++03 language standard. Do not use C++11 (or higher) syntax.)
Input: Coordinates for Point A (x1 and y1) and coordinates for Point B (x2 and y2). The user can enter any coordinates (input parameters) from the keyboard. Output: The distance between Point A and Point B. Picture Build a command-line C++ application that allows user to calculate and display the distance between two points. The coordinates of the points for A and B will be entered by the user. The distance formula is a variant of the Pythagorean Theorem that you used back in geometry class. Ex: d=sqrt[(x2-x1)^2+(y2-y1)^2]. (All code must be written using the C++03 language standard. Do not use C++11 (or higher) syntax.)
Input: Coordinates for Point A (x1 and y1) and coordinates for Point B (x2 and y2). The user can enter any coordinates (input parameters) from the keyboard. Output: The distance between Point A and Point B. Picture Input: Coordinates for Point A (x1 and y1) and coordinates for Point B (x2 and y2). The user can enter any coordinates (input parameters) from the keyboard. Output: The distance between Point A and Point B. Picture

Explanation / Answer

SOLUTION:

#include <iostream>
#include <cmath>


using namespace std;
int ch;
double x;
double y;
double a;
double b;
double answer;

double distanceBetweenTwoPoints(double x, double y, double a, double b);

int main(){

cout << "Enter the points for the coordinates";
cout << endl;
cout << "Point x for first coordinates: ";
cin >> x;
cout << endl;
cout << endl;
cout << "Point y for first coordinate: ";
cin >> y;
cout << endl;
cout << endl;
cout << "Point x for the second coordinate: ";
cin >> a;
cout << endl;
cout << endl;
cout << "Point y for the second coordinate: ";
cin >> b;
cout << endl;
cout << endl;
answer = distanceBetweenTwoPoints(x, y, a, b);
cout << "The answer is " << answer;

}

double distanceBetweenTwoPoints(double x, double y, double a, double b){
return sqrt(pow(x - a, 2) + pow(y - b, 2));
}


OUTPUT:-

Enter the points for the coordinates

Point x for first coordinates: 3
Point y for first coordinate: 4

Point x for the second coordinate: 7
Point y for the second coordinate: 7

The answer is 5

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote