I have trouble putting this program below into a switch statement at the next program under "case 3" Im new at C++ so its difficult to see the problem. I only get error everytime and its getting really on my nerves. Anyone who knows what to do?
The first one her is a program who will calculate the distance between two geographical points on the Earth's but i need to get it under case 3 instead in the program after this one.
# include <iostream>
# include <cstdio>
# include <cmath>
usingnamespace std;
double getdistance(double x1,double y1,double x2,double y2)
{
double radius;
radius=6371; // radius km
double pi=3.14159265;
// X og Y coord
x1=(x1/180)*pi;
y1=(y1/180)*pi;
x2=(x2/180)*pi;
y2=(y2/180)*pi;
if (x1==x2 && y1==y2)
return 0;
else
{
if ((sin(x2)*sin(x1)+cos(x2)*cos(x1)*cos(y2-y1))>1)
return radius*acos(1.0);
elsereturn radius*acos(sin(x2)*sin(x1)+cos(x2)*cos(x1)*cos(y2-y1));
}
}
int main()
{
double x1,y1,x2,y2;
cout<<"Write the coords you like to calculate distance from: \n";
cin>>x1>>y1;
cin>>x2>>y2;
cout<<"distance in km : \n";
cout<<getdistance(x1,y1,x2,y2)<<endl;
return 0;
}
This is the program i want to put it to under "case 3"
I've also had cases where, if you're declaring variables within a case block, you need to have the whole block within curly-braces. It may be affecting you here, but it's only a possibility.
Also, what's the forward declaration of function 'volume' doing at line 44? I don't see you using it.