Hi guys, I need some help.
Im doing a project for class, im new to C++, and I cant quite figure out how to pass all fo the texts for the project.
This is my code:
#include <iostream>
#include <math.h>
#include<iomanip>
using namespace std;
double calculateDistance(int x1, int y1, int z1, int x2, int y2, int z2)
{
return sqrt((x2-x1)(x2-x1)+(y2-y1)(y2-y1)+(z2-z1)*(z2-z1));
}
int main() {
int x1,y1,z1,x2,y2,z2;
cout<<"Please enter the coordinates of point-01:"<<endl;
cin>>x1>>y1>>z1;
cout<<"Please enter the coordinates of point-02:"<<endl;
cin>>x2>>y2>>z2;
cout<<"The distance between points (1,1,1) and (0,0,0) is:"<<endl;
cout<<setprecision(3)<<calculateDistance(0,0,0,x1,y1,z1)<<endl;
cout<<"The distance between points (3,4,5) and (0,0,0) is:"<<endl;
cout<<setprecision(3)<<calculateDistance(0,0,0,x2,y2,z2)<<endl;
cout<<"The distance between points (1,1,1) and (3,4,5) is:"<<endl;
cout<<setprecision(3)<<calculateDistance(x1,y1,z1,x2,y2,z2)<<endl;
}
I also attached it to the post.
The problem im facing is that there are 3 tests that I need to pass simultaneously. I have passed the first test, but for the second test, the values for "1,1,1" need to be "2,4,6" and the values for "3,4,5" need to be "7,8,9". For the third test, the values for "3,4,5" need to be "3,3,3".
Keep in mind I have to pass all 3 tests at the same time. I cant just do 1 test then go change the number value.
Could someone please help me adjust my code accordingly?
In the post images, you can see the explanation for my failure of test 2. The problem im facing is that I cant just flat out change the number values or I fail test 1.