The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 3 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Could you please help me with this C++ question? Please use basic c++ code.
Â
Prompt the user for two points (x1, y1), (y1, y2). Write a function that calculates the distance between the points. For a refresher on how to calculate the distance between two points, click here: http://www.mathwarehouse.com/algebra/distance_formula/index.php
Start with this code:
#include <iostream>
// YOUR CODE GOES BELOW HERE
// TO HERE
// DO NOT CHANGE ANYTHING BELOW HERE
int main() {
double x1, y1, x2, y2;
cout << "Enter x1: ";
cin >> x1;
cout << x1 << endl;
cout << "Enter y1: ";
cin >> y1;
cout << y1 << endl;
cout << "Enter x2: ";
cin >> x2;
cout << x2 << endl;
cout << "Enter y2: ";
cin >> y2;
cout << y2 << endl;
cout << "The distance is ";
cout << distance(x1, y1, x2, y2) << endl;
return 0;
}
Â
Â
Â
Â
Â
Sample run #1:
Enter x1: -5
Enter y1: 8
Enter x2: 0
Enter y2: -4
The distance is 13
Â
Â
Â
Sample run #2:
Enter x1: 12.5
Enter y1: 18.7
Enter x2: -13.9
Enter y2: -29.5
The distance is 54.9563
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly