Last active
June 15, 2020 00:34
-
-
Save daniel7byte/8d1b1951edeee10b0c7498ac822585c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <iostream> | |
using namespace std; | |
main() | |
{ | |
char planeta[8], planetados[8]; | |
int numerouno, numerodos, distanciaunoperihelio = 0, distanciaunoafelio = 0, distanciadosperihelio = 0, distanciadosafelio = 0; | |
cout<<" Listado de planetas:"<<endl; | |
cout<<" 1. Mercurio"<<endl; | |
cout<<" 2. Venus"<<endl; | |
cout<<" 3. Tierra"<<endl; | |
cout<<" 4. Marte"<<endl; | |
cout<<" 5. Jupiter"<<endl; | |
cout<<" 6. Saturno"<<endl; | |
cout<<" 7. Urano"<<endl; | |
cout<<" 8. Neptuno \n"<<endl; | |
cout<<" Introduzca el numero del primer planeta que desea: "; | |
cin>>numerouno; | |
if ( numerouno >= 1 && numerouno < 9 ) | |
{ | |
switch ( numerouno ) | |
{ | |
case 1 : strcpy( planeta, "Mercurio" ); | |
distanciaunoperihelio = 46001009 ; | |
distanciaunoafelio = 69817445; | |
break; | |
case 2 : strcpy( planeta, "Venus" ); | |
distanciaunoperihelio = 107476170; | |
distanciaunoafelio = 108942780 ; | |
break; | |
case 3 : strcpy( planeta, "Tierra" ); | |
distanciaunoperihelio = 147098291; | |
distanciaunoafelio = 152098233; | |
break; | |
case 4 : strcpy( planeta, "Marte" ); | |
distanciaunoperihelio = 206645215; | |
distanciaunoafelio = 249232432; | |
break; | |
case 5 : strcpy( planeta, "J\xA3piter" ); | |
distanciaunoperihelio = 740679835; | |
distanciaunoafelio = 816001807; | |
break; | |
case 6 : strcpy( planeta, "Saturno" ); | |
distanciaunoperihelio = 1349823615; | |
distanciaunoafelio = 1503509229; | |
break; | |
case 7 : strcpy( planeta, "Urano" ); | |
distanciaunoperihelio = 2734998229; | |
distanciaunoafelio = 3006318143; | |
break; | |
case 8 : strcpy( planeta, "Neptuno" ); | |
distanciaunoperihelio = 4459753056 ; | |
distanciaunoafelio = 4537039826; | |
break; | |
} | |
cout<<" Primer planeta seleccionado es: "<<planeta<<endl; | |
} | |
else | |
{ | |
cout<<" ERROR: no esta asociado a ningun planeta"<<endl; | |
} | |
cout<<" Introduzca numero del segundo planeta que desea: "; | |
cin>>numerodos; | |
if ( numerodos >= 1 && numerodos < 9 ) | |
{ | |
switch ( numerodos ) | |
{ | |
case 1 : strcpy( planetados, "Mercurio" ); | |
distanciadosperihelio =46001009; | |
distanciadosafelio = 69817445; | |
break; | |
case 2 : strcpy( planetados, "Venus" ); | |
distanciadosperihelio = 107476170; | |
distanciadosafelio = 108942780; | |
break; | |
case 3 : strcpy( planetados, "Tierra" ); | |
distanciadosperihelio = 147098291; | |
distanciadosafelio = 152098233; | |
break; | |
case 4 : strcpy( planetados, "Marte" ); | |
distanciadosperihelio = 206645215; | |
distanciadosafelio = 249232432; | |
break; | |
case 5 : strcpy( planetados, "J\xA3piter" ); | |
distanciadosperihelio = 740679835; | |
distanciadosafelio = 816001807; | |
break; | |
case 6 : strcpy( planetados, "Saturno" ); | |
distanciadosperihelio = 1349823615; | |
distanciadosafelio = 1503509229; | |
break; | |
case 7 : strcpy( planetados, "Urano" ); | |
distanciadosperihelio = 2734998229; | |
distanciadosafelio = 3006318143; | |
break; | |
case 8 : strcpy( planetados, "Neptuno" ); | |
distanciadosperihelio = 4459753056; | |
distanciadosafelio = 4537039826; | |
break; | |
} | |
cout<<" El segundo planeta seleccionado es: "<<planetados<<endl; | |
} | |
else | |
{ | |
cout<<" ERROR: no esta asociado a ningun planeta"<<endl; | |
} | |
int perihelio = distanciadosperihelio - distanciaunoperihelio; | |
if(perihelio < 0) perihelio = perihelio * (-1); | |
int afelio = distanciadosafelio - distanciaunoafelio; | |
if(afelio < 0) afelio = afelio * (-1); | |
float perihelioUA = (perihelio * 0.0000000066846); | |
float afelioUA = (afelio * 0.0000000066846); | |
cout<<endl<<" Distancia en Perihelio "<<perihelio<<" Km y "<<perihelioUA<<" UA"<<endl; | |
cout<<endl<<" Distancia en Afelio "<<afelio<<" Km y "<<afelioUA<<" UA"<<endl; | |
system("PAUSE"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment