Question: If you are in a city and have to walk from where you are, having planar coordinates (0, 0), to a destination having planar coordinates (x, y), then there are two ways of computing the...


in C++


Question: If you are in a city and have to walk from where you are, having planar coordinates (0, 0),<br>to a destination having planar coordinates (x, y), then there are two ways of computing the distance<br>you have to travel. One is called the euclidean distance<br>rl<br>Vx² + y²<br>Note that this distance would require you to cut across lawns and through buildings.<br>There is another way to measure distance called the taxi-cab distance<br>r2 = |x|+ |y|<br>which is the distance a taxi-cab would have to travel along the city blocks.<br>Write a program which reads the destination coordinates, (x, y), and calls a single function,<br>distance (), which computes and sets both the euclidean distance and the taxi-cab distance in the<br>main program. The main program (not the function) must print both distances.<br>Your program output should look like:<br>Enter x and y: 3 4<br>The destination coordinates are (3.000, 4.000)<br>The euclidean distance is 5.000<br>The taxicab<br>distance is 7.000<br>For marking purposes run your program twice using destinations: (2,4) and (-3,4).<br>Copy and paste your program into the box below.<br>#include <stdio.h><br>#include <math.h><br>/* function prototype */<br>int main(void)<br>{<br>/* you fill in here */<br>return 0;<br>}<br>/* function definition */<br>

Extracted text: Question: If you are in a city and have to walk from where you are, having planar coordinates (0, 0), to a destination having planar coordinates (x, y), then there are two ways of computing the distance you have to travel. One is called the euclidean distance rl Vx² + y² Note that this distance would require you to cut across lawns and through buildings. There is another way to measure distance called the taxi-cab distance r2 = |x|+ |y| which is the distance a taxi-cab would have to travel along the city blocks. Write a program which reads the destination coordinates, (x, y), and calls a single function, distance (), which computes and sets both the euclidean distance and the taxi-cab distance in the main program. The main program (not the function) must print both distances. Your program output should look like: Enter x and y: 3 4 The destination coordinates are (3.000, 4.000) The euclidean distance is 5.000 The taxicab distance is 7.000 For marking purposes run your program twice using destinations: (2,4) and (-3,4). Copy and paste your program into the box below. #include #include /* function prototype */ int main(void) { /* you fill in here */ return 0; } /* function definition */

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here