Hey Guys,
New to programming, but slowly getting the hang of it. I'm a little stuck though right now.
I have to create a program that calculates Orbital Velocity (VC). The User must enter a the distance to the earth (in km/Height) and the program needs to calculate VC based on an equation I have. If the user enters a number less than 320, it must be seen as invalid as the satellite would burnup up with a VC that low. So if the user enters a number less than 320, I would like the program to ask for the Height again and recalculate.
I believe I've got everything properly defined but im running into errors, any help would be greatly appreciated. I'm quite new to this but an slowely and surely coming along! Thanks in advance!
Code:
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main(void)
{
float G, RE, M, VC, R, H, REDO, H_REDO, R_TWO;
/*G=Universal Gravitational Constant*/
/*RE=Mean Earth Radius*/
/*M=Mass of Planet*/
/*VC=Oribal/Circular Velocity*/
/*R=Distance from sattelite to centre of planet*/
/*H=Height of Orbit in Kilometers - User MUST enter this to preform calculation*/
printf("Please enter the height of the satellite from Earth, in KM :\n ");
scanf("%f", &H);
G = 6.67E-11.00;/*Define G Value Here, before semi-colon*/
RE = 6378000.0;/*Define RE Value Here, before semi-colon*/
M = 5.98E24;/*Define M Value Here, before semi-colon*/
R = RE + H;/*Define R value Here - Remeber the value of H is already stored from the user input, before semi-colon*/
VC = sqrt(G * M / R) / 1000.00;/*Define the calculation needed to define Orbital/circular velocity, before semi-colon*/
REDO = sqrt(G * M / R_TWO);
R_TWO = RE + H_REDO;
if (H < 320);
{
printf("\nThe entered value is too low causeing the satellite to slow down and burn up");
printf("\n\nRe-enter a value greater than 320:");
scanf("%f", &H_REDO);
printf("\nVC: %.2fkm/s",REDO);
}
else
printf("\nVC: %.2fkm/s",VC);
_getch();
return;
}
Error Messages:
Code:
1>c:\users\matthew\documents\visual studio 2008\projects\velocity2\velocity2\velocity2.cpp(18) : warning C4305: '=' : truncation from 'double' to 'float'
1>c:\users\matthew\documents\visual studio 2008\projects\velocity2\velocity2\velocity2.cpp(18) : error C2143: syntax error : missing ';' before 'constant'
1>c:\users\matthew\documents\visual studio 2008\projects\velocity2\velocity2\velocity2.cpp(20) : warning C4305: '=' : truncation from 'double' to 'float'
1>c:\users\matthew\documents\visual studio 2008\projects\velocity2\velocity2\velocity2.cpp(22) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
1>c:\users\matthew\documents\visual studio 2008\projects\velocity2\velocity2\velocity2.cpp(27) : warning C4390: ';' : empty controlled statement found; is this the intent?
1>c:\users\matthew\documents\visual studio 2008\projects\velocity2\velocity2\velocity2.cpp(33) : error C2181: illegal else without matching if