Quiz 3-Finally

Hey world…

Just to tell you that I finally finished the entire work for this partial, I have got help from the professor Ken via Twitter, I asked for help and he did answered, also it took like a minute really!!!

Quiz three was divided in two programs or sections… the first one is related with the Cartesian Plane, and some points in it, the thing is that the program is able to calculate the distance between those two point, which are given by the user randomly, using the Pitagora’s theorem to solve it.

Also I had difficulties with the function formula (synthesis), but was no problem i manage to solve the problem with a different algorithm. As you can see part of the algorithm is as a “comment”, just to ask in class what is wrong with it and how I should have done it.

#SolvingProblemsAsEngineer #IMD

//CODE:

# include <iostream>
# include <cmath>
using namespace std;

/*int x1, x2, y, y2;

void Distance(int x1, int x2, int y, int y2) {
int dx, dy, dist, C;
dx=(x2-x1);
dy=(y2-y);
C=((dx*dx)+(dy*dy));
dist=sqrt(C);
std::cout << “dx–“<<dx << std::endl;
std::cout << “dy–“<<dy << std::endl;
std::cout << “The distance between the points is… “<<dist << std::endl;
}*/

int main(int argc, char const *argv[]) {
int dx, dy, x1, x2, y, y2, dist, C;

std::cout << “This program calculates the distance between two points in the cartesian plane.” << std::endl;
std::cout << “Next enter the coordenates of the first point” << std::endl;
std::cout << “Please enter x1)” << std::endl;
std::cin >> x1;
std::cout << “Pease enter y1” << std::endl;
std::cin >> y;
std::cout << “Please enter x2” << std::endl;
std::cin >> x2;
std::cout << “Please enter y2” << std::endl;
std::cin >> y2;

dx=(x2-x1);
dy=(y2-y);
C=(pow(dx,2)+pow(dy,2));
dist=sqrt(C);
std::cout << “The distance between the points

Captura de pantalla 2016-02-17 a las 19.56.15

“<<dist << std::endl;
//Distance();
return 0;
}

Captura de pantalla 2016-02-17 a las 19.56.15

CC BY-SA 4.0 Quiz 3-Finally by everolivares is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.