/***********************************************************/ /*Programname: cosmos1.c */ /*The presented tool provides an overview of cosmic */ /*distances. Therefore it distinguishes between */ /*planetary and solar distances on the basis */ /*of their average distance from our central sun. */ /*One can determine distances to distant suns out there, */ /*as well as distances that the light travels in a given */ /*period of time. */ /*open-source, freeware */ /*Author: Klaus Weyell khabs@khabs.com */ /*check for updates: http://www.khabs.com */ /*first implementation: 14.10.2001, */ /*update:6.3.2002, update 22.-4.5.2003 */ /*remarks: no numbertest yet */ /***********************************************************/ /*---------------------------------------------------------*/ /* used C - Libraries */ /*---------------------------------------------------------*/ #include #include #include /*---------------------------------------------------------*/ /* constant values by preprocessor definition */ /*---------------------------------------------------------*/ #define LICHTKONSTANTE 299792.46 #define JAHRESDAUER 365.2422 /*---------------------------------------------------------*/ /* defined types */ /*---------------------------------------------------------*/ typedef struct /*used in planetausgabe and kmlicht1*/ { int lichtstunden; int lichtminuten; double lichtsekunden; }zeit; typedef char* string; /*----------------------------------------------------------------------------*/ /* global symbolic constant values for "sonnen"(sun) - functions */ /*----------------------------------------------------------------------------*/ const float STERNE[21]={4.3, 8.8, 11.4, 15.5, 23, 26, 32, 34, 41, 45, 68, 86, 136, 142, 163, 200, 270, 400, 550, 650, 1600}; const string STERNE_NAMEN[21]={"Bungula", "Sirius", "Procyon", "Atair","Fomalhaut", "Vega", "Arkturus", "Pollux", "55Cancri", "Capella", "Aldebaran", "Regulus", "Agena", "Achernar", "Acrux", "Spica", "Betelgeuze", "Antares", "Canopus", "Rigel", "Deneb"}; const string STERNBILD[21]={"Centaurus", "Canis Major", "Canis Minor", "Aquila", "Piscis Austrinus", "Lyra", "Bootes", "Gemini", "Cancer", "Auriga", "Taurus", "Leo", "Centaurus", "Eridanus", "Crux", "Virgo", "Orion", "Scorpius", "Carina", "Orion", "Cygnus"}; /*----------------------------------------------------------------------------*/ /* global symbolic constant values for "planet" - functions */ /*----------------------------------------------------------------------------*/ const double PLANETEN[10]={58000000.0,108000000.0,150000000.0,228000000.0,778000000.0,1427000000.0,2869000000.0,4498000000.0,5900000000.0, 0.0}; const string PLANETENNAMEN[10]={"Merkur", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto", "Sun"}; /*---------------------*/ /* prototypes */ /*---------------------*/ /*main begins in line 75*/ void vor_sonnen(); /*Zeilennummer: 125*/ int sonnen(); /*Zeilennummer: 148*/ void sonnenausgabe(); /*Zeilennummer: 190*/ void gesamt_sonnen(); /*Zeilennummer: 214*/ void vor_planet(); /*Zeilennummer: 344*/ int planet(); /*Zeilennummer: 367*/ void planetausgabe(int, int); /*Zeilennummer: 413*/ void gesamt_planet(); /*Zeilennummer: 468*/ int lichtkm(); /*Zeilennummer: 530*/ double lichtkm1(double); /*Zeilennummer: 609*/ int kmlicht(); /*Zeilennummer: 624*/ zeit kmlicht1(double); /*Zeilennummer: 702*/ int numeriktest(int test); /*Zeilennummer: 731*/ int stars(); /*Zeilennummer: 757*/ int line(); /*Zeilennummer: 772*/ /*----------------------*/ /* Start of Program */ /*----------------------*/ int main() { int start=0, lichter=0; system("clear"); stars(); puts("\n* This program is meant to analyze distances to *\n* celestial bodies in our neighborhood and thereby *\n* to obtain a clearer knowledge of our location. *"); stars(); for(;;) { puts("\n\nCOSMIC DISTANCES"); printf("\n1\tsun to sun distances\n2\tdistances within our solar system\n3\tlightdistances\n0\texit\n\n"); printf("\nPlease select an item from the menu:\\> "); scanf("%i",&start); numeriktest(start); switch(start){ case 1: vor_sonnen(); break; case 2: vor_planet(); break; case 3: puts("\nLIGHTDISTANCES"); puts("\n1\tconverting lightdistances to kilometres\n2\tconverting kilometres to lightdistances\n0\tcancel"); printf("\nPlease select an item from the menu:\\> "); scanf("%i",&lichter); numeriktest(lichter); if(lichter==1) lichtkm(); else if(lichter==2) kmlicht(); else if(lichter==0) break; else puts("\nincorrect entry!\a"); break; case 0: exit(-1); default: puts("\nincorrect entry!\a"); break;} } fflush(stdin); return 0; } /*----------------------------------------------------------------------*/ /* Function: vor_sonnen() */ /* responsibility: The void function vor_sonnen is a switch-point */ /* between sonnen() and gesamt_sonnen(), providing either */ /* sun-to-remote-star-distances or a complete list of stars. */ /*----------------------------------------------------------------------*/ void vor_sonnen() { int check=0; do { puts("\n\nSUN TO SUN DISTANCES\n"); puts("1\tget a single distance"); puts("2\tget complete list"); puts("0\tcancel\n"); printf("Please select an item from the menu:\\> "); scanf("%d", &check); }while(check<0||check>2); if(check==1)sonnen(); else if(check==0)return; else gesamt_sonnen(); } /*----------------------------------------------------------------------*/ /* Function: sonnen() */ /* responsibility: This function asks the user to select a distant */ /* sun from a menu and calls the function */ /* void sonnenausgabe(ziel-1) with an int value which is*/ /* as an index of the constant global arrays */ /* about stars(STERNE), see lines 45-47. */ /* return value: 0 to vor_sonnen */ /*----------------------------------------------------------------------*/ int sonnen() { int ziel=1; do { printf("\n1 Bungula\t2 Sirius\t3 Procyon\n"); printf("4 Atair\t\t5 Fomalhaut\t6 Vega\n"); printf("7 Arkturus\t8 Pollux\t9 55Cancri\n"); printf("10 Capella\t11 Aldebaran\t12 Regulus\n"); printf("13 Agena\t14 Achernar\t15 Acrux\n"); printf("16 Spica\t17 Betelgeuze\t18 Antares\n"); printf("19 Canopus\t20 Rigel\t21 Deneb\n0 cancel\n"); printf("\nPlease select a star from the menu:\\> "); scanf("%i",&ziel); numeriktest(ziel); if (ziel>21||ziel<0) { ziel = 1; puts("\nincorrect entry!\a"); } else if(ziel==0) break; else { sonnenausgabe(ziel-1); } }while(ziel<22&&ziel>0); return 0; } /*---------------------------------------------------------------------*/ /* Function: void sonnenausgabe(int i) */ /* responsibility: This function takes a value, i, from sonnen() */ /* and shoves it to stdout using printf. */ /* i is used as an index of the constant global arrays */ /* STERNE[21], STERNE_NAMEN[21] and STERNBILD[21]. */ /* Parameter: int i */ /* return: void */ /*---------------------------------------------------------------------*/ void sonnenausgabe(int i) { int km=0; printf("\n%s in the constellation of %s is %.1f Lightyears away from Earth.\n", STERNE_NAMEN[i], STERNBILD[i], STERNE[i]); printf("\nConvert into km?\t1 yes\t2 no:\\> "); scanf("%i",&km); numeriktest(km); if(km==1) printf("\n%s in the constellation of %s is %.3lf kilometres away from Earth.\n", STERNE_NAMEN[i], STERNBILD[i], lichtkm1(STERNE[i])); else if(km==2) return; else puts("\nincorrect entry!\a"); } /*--------------------------------------------------------------------*/ /* Function: gesamt_sonnen() */ /* responsibility: The void function gesamt_sonnen shows a list of */ /* distant suns. The switch - instruction inside the for - */ /* iteration is necessary to format the output. */ /*--------------------------------------------------------------------*/ void gesamt_sonnen() { const float *zSterne = STERNE; const string *zSterne_namen = STERNE_NAMEN; const string *zSternbilder = STERNBILD; int i; stars(); puts("\nSun\t\tConstellation\t Distance(Lightyears)"); line(); for(i=0;i<21;i++) { switch(i) { case 0: printf("%s\t\t", *zSterne_namen++); printf("%s\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 1: printf("%s\t\t", *zSterne_namen++); printf("%s\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 2: printf("%s\t\t", *zSterne_namen++); printf("%s\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 3: printf("%s\t\t", *zSterne_namen++); printf("%s\t\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 4: printf("%s\t", *zSterne_namen++); printf("%s", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 5: printf("%s\t\t", *zSterne_namen++); printf("%s\t\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 6: printf("%s\t", *zSterne_namen++); printf("%s\t\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 7: printf("%s\t\t", *zSterne_namen++); printf("%s\t\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 8: printf("%s\t", *zSterne_namen++); printf("%s\t\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 9: printf("%s\t\t", *zSterne_namen++); printf("%s\t\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 10: printf("%s\t", *zSterne_namen++); printf("%s\t\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 11: printf("%s\t\t", *zSterne_namen++); printf("%s\t\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 12: printf("%s\t\t", *zSterne_namen++); printf("%s\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 13: printf("%s\t", *zSterne_namen++); printf("%s\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 14: printf("%s\t\t", *zSterne_namen++); printf("%s\t\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 15: printf("%s\t\t", *zSterne_namen++); printf("%s\t\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 16: printf("%s\t", *zSterne_namen++); printf("%s\t\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 17: printf("%s\t\t", *zSterne_namen++); printf("%s\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 18: printf("%s\t\t", *zSterne_namen++); printf("%s\t\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 19: printf("%s\t\t", *zSterne_namen++); printf("%s\t\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; case 20: printf("%s\t\t", *zSterne_namen++); printf("%s\t\t", *zSternbilder++); printf(" %.1f \n", *zSterne++); break; } } line(); stars(); } /*----------------------------------------------------------------------*/ /* Function: vor_planet() */ /* responsibility: The void Funktion vor_planet is a switch-point */ /* between planet() and gesamt_planet(), that put out single */ /* planetary distances or a complete list. */ /*----------------------------------------------------------------------*/ void vor_planet() { int check=0; do { puts("\n\nTHE PLANETS OF OUR SOLAR SYSTEM\n"); puts("1\tsingle distance"); puts("2\tcomplete list"); puts("0\tcancel\n"); printf("Please select an item from the menu:\\> "); scanf("%d", &check); }while(check<0||check>2); if(check==1)planet(); else if(check==0)return; else gesamt_planet(); } /*----------------------------------------------------------------------*/ /* Function: planet() */ /* responsibility: This function asks the user, to choose two planets */ /* from a menu which it uses to call */ /* planetausgabe(splanet-1, zplanet-1) with 2 arguments, */ /* serving as indexes of arrays: double PLANETEN[10] and */ /* string PLANETENNAMEN[10]. */ /* return: 0 to vor_planet */ /*----------------------------------------------------------------------*/ int planet() { int splanet = 0; int zplanet = 0; do { puts("\nDISTANCES WITHIN OUR SOLAR SYSTEM\n"); printf("1 Merkur\t2 Venus\t\t3 Earth\n4 Mars\t\t5 Jupiter\t6 Saturn\n"); printf("7 Uranus\t8 Neptune\t9 Pluto\n10 Sun\t\t0 cancel\n"); printf("\nPlease select a startplanet:\\> "); scanf("%i",&splanet); numeriktest(splanet); printf("\nPlease select a target:\\> "); scanf("%i",&zplanet); numeriktest(zplanet); if(splanet==zplanet) printf("\nThe distance is 0 km.\n"); else if((splanet>11||splanet<0)||(zplanet>11||zplanet<0)) { splanet = zplanet = 1; puts("\nincorrect entry!\a"); } else if(splanet==0||zplanet==0) break; else if(splanet0)&&(zplanet<11&&zplanet>0)); return 0; } /*----------------------------------------------------------------------------------------*/ /* Function: void planetausgabe(int planet1, int planet2) */ /* responsibility: This function takes 2 values, planet1, planet2, from planet() */ /* to output them to stdout using printf. Both variables planet1 */ /* and planet2 serving as an index to global arrays: PLANETEN[10], */ /* PLANETENNAMEN[10], thereby keeping both arrays in touch with each other. */ /* Parameter: int planet1, int planet2 */ /* return: void */ /*----------------------------------------------------------------------------------------*/ void planetausgabe(int planet1, int planet2) { int licht = 0; double planet = 0.0; zeit streckenzeit; streckenzeit.lichtstunden = 0; streckenzeit.lichtminuten = 0; streckenzeit.lichtsekunden = 0.0; if(planet2==9||planet1==9) { if(planet2==9) printf("\nThe average distance of planet %s to Sun equals %.0lf km\n", PLANETENNAMEN[planet1], PLANETEN[planet1]); if (planet1==9) printf("\nThe average distance of planet %s to Sun equals %.0lf km\n", PLANETENNAMEN[planet2], PLANETEN[planet2]); printf("\nWould you like to know, how long it would take the light to travel this distance?\n1 yes\t2 no:\\> "); scanf("%i",&licht); numeriktest(licht); if(licht==1) { planet = PLANETEN[planet1]; streckenzeit = kmlicht1(planet); printf("\nThe distance of planet %s to Sun takes the light %i hours,\n %i minutes und %lf seconds\n", PLANETENNAMEN[planet1], streckenzeit.lichtstunden, streckenzeit.lichtminuten, streckenzeit.lichtsekunden); } else if(licht==2) return ; } else { printf("\nThe distance between %s and %s differs from %.0lf km\nin conjunction and %.0lf km in opposition.\n", PLANETENNAMEN[planet1], PLANETENNAMEN[planet2], PLANETEN[planet2]- PLANETEN[planet1], PLANETEN[planet2]+ PLANETEN[planet1]); printf("\nWould you like to know, how long it would take the light to travel these distances?\n1 yes\t2 no:\\> "); scanf("%i",&licht); numeriktest(licht); if(licht==1) { planet = PLANETEN[planet2] - PLANETEN[planet1]; streckenzeit = kmlicht1(planet); printf("\nThe light is on its way %i hours,\n %i minutes und %lf seconds respective\n", streckenzeit.lichtstunden, streckenzeit.lichtminuten, streckenzeit.lichtsekunden); planet = PLANETEN[planet2] + PLANETEN[planet1]; streckenzeit = kmlicht1(planet); printf("%i hours, %i minutes und %lf seconds.\n", streckenzeit.lichtstunden, streckenzeit.lichtminuten, streckenzeit.lichtsekunden); } else if(licht==2||licht==0) return ;} } /*------------------------------------------------------------------*/ /* Function: gesamt_planet() */ /* responsibility: The void function gesamt_planet puts out a */ /* list of planets. The switch - instruction in the for - */ /* loop is needed to format output. */ /*------------------------------------------------------------------*/ void gesamt_planet() { const string *zPlanetennamen = PLANETENNAMEN; const double *zPlaneten = PLANETEN; int i; stars(); puts("\nPlanet\t\tDistance from Sun(kilometres)"); line(); for(i=0;i<9;i++) { switch(i) { case 0: printf("%s\t\t", *zPlanetennamen++); printf(" %.0f \n", *zPlaneten++); break; case 1: printf("%s\t\t", *zPlanetennamen++); printf(" %.0f \n", *zPlaneten++); break; case 2: printf("%s\t\t", *zPlanetennamen++); printf(" %.0f \n", *zPlaneten++); break; case 3: printf("%s\t\t", *zPlanetennamen++); printf(" %.0f \n", *zPlaneten++); break; case 4: printf("%s\t\t", *zPlanetennamen++); printf(" %.0f \n", *zPlaneten++); break; case 5: printf("%s\t\t", *zPlanetennamen++); printf("%.0f \n", *zPlaneten++); break; case 6: printf("%s\t\t", *zPlanetennamen++); printf("%.0f \n", *zPlaneten++); break; case 7: printf("%s\t\t", *zPlanetennamen++); printf("%.0f \n", *zPlaneten++); break; case 8: printf("%s\t\t", *zPlanetennamen++); printf("%.0f \n", *zPlaneten++); break; } } line(); puts("average distances"); stars(); } /*----------------------------------------------------------------------*/ /* Function: lichtkm() */ /* responsibility: This function asks its user, to select */ /* lightseconds, lightminutes, lighthours, days, */ /* months or years from a menu and puts out the distances */ /* the light would travel in the appropriate durations. */ /* Constant values LICHTKONSTANTE and */ /* JAHRESDAUER are used to calculate the distances. */ /* return: 0 to main */ /*----------------------------------------------------------------------*/ int lichtkm( ) { int selektor; double ein; puts("\nCONVERT LIGHTDISTANCES TO KM"); puts("\nDistances that the light travels in"); printf("1 seconds\t2 minutes\t3 hours\n4 days\t\t5 weeks\t\t6 months\n7 years\t\t0 cancel\n"); printf("Your selection:\\> "); scanf("%i",&selektor); numeriktest(selektor); switch(selektor){ case 1: { printf("\nHow many lightseconds would you like to convert to km?:\\> "); scanf("%lf",&ein); printf("%.1lf lightseconds are %.2lf km.\n",ein,ein*LICHTKONSTANTE); } break; case 2: { printf("\nHow many lightminutes would you like to convert to km?:\\> "); scanf("%lf",&ein); printf("%.1lf lightminutes are %.2lf km.\n",ein,ein*60*LICHTKONSTANTE); } break; case 3: { printf("\nHow many lighthours would you like to convert to km?:\\> "); scanf("%lf",&ein); printf("%.1lf lighthours are %g km.\n",ein,ein*3600*LICHTKONSTANTE); } break; case 4: { printf("\nHow many lightdays would you like to convert to km?:\\> "); scanf("%lf",&ein); printf("%.1lf lightdays are %g km.\n",ein,ein*3600*24*LICHTKONSTANTE); } break; case 5: { printf("\nHow many lightweeks would you like to convert to km?:\\> "); scanf("%lf",&ein); printf("%.1lf lightweeks are %g km.\n",ein,ein*3600*24*7*LICHTKONSTANTE); } break; case 6: { printf("\nHow many lightmonths would you like to convert to km?:\\> "); scanf("%lf",&ein); printf("%.1lf lightmonths are %g km.\n",ein,ein*3600*24*30*LICHTKONSTANTE); } break; case 7: { printf("\nHow many lightyears would you like to convert to km?:\\> "); scanf("%lf",&ein); printf("%.1lf lightyears are %g km.\n",ein,ein*3600*24*JAHRESDAUER*LICHTKONSTANTE); } break; case 0: break; default: puts("\nincorrect entry!\a"); break; }return 0; } /*----------------------------------------------------------------------------------*/ /* Function: double lichtkm1(double) */ /* responsibility: This function takes a value, lightyears, from sonnen() */ /* and converts them to kilometres. */ /* */ /* Global constant values LICHTKONSTANTE and */ /* JAHRESDAUER are used. */ /* Parameter: double eingabe */ /* return: Kilometres as double to sonnenausgabe() */ /*----------------------------------------------------------------------------------*/ double lichtkm1(double eingabe) { return (eingabe*3600*24*JAHRESDAUER*LICHTKONSTANTE); } /*----------------------------------------------------------------------------*/ /* Function: kmlicht() */ /* responsibility: This function asks the user, to */ /* provide a distance in kilometres, */ /* which is then converted into a lightdistance, */ /* light- seconds, minutes, hours, days, months */ /* and years are distinguished. */ /* Global constant values LICHTKONSTANTE and */ /* JAHRESDAUER are used. */ /* return: 0 to main() */ /*----------------------------------------------------------------------------*/ int kmlicht() { double kilometer = 0.0; double lichtsek = 0.0; unsigned lichtmin = 0; unsigned lichtstd = 0; unsigned lichttage = 0; unsigned lichtwochen = 0; unsigned lichtmonate = 0; unsigned lichtjahre = 0; puts("\nCONVERT DISTANCES IN KM TO LIGHTDISTANCES"); printf("\nPlease enter a distance in kilometres:\\> "); scanf("%lf", &kilometer); if(kilometer>=(3600*24*JAHRESDAUER*LICHTKONSTANTE)) { lichtjahre = kilometer / (3600*24*JAHRESDAUER*LICHTKONSTANTE); kilometer = kilometer - lichtjahre*3600*24*JAHRESDAUER*LICHTKONSTANTE; } if(kilometer>=(3600*24*30*LICHTKONSTANTE)) { lichtmonate = kilometer / (3600*24*30*LICHTKONSTANTE); kilometer = kilometer - lichtmonate*3600*24*30*LICHTKONSTANTE; } if(kilometer>=(3600*24*7*LICHTKONSTANTE)) { lichtwochen = kilometer / (3600*24*7*LICHTKONSTANTE); kilometer = kilometer - lichtwochen*3600*24*7*LICHTKONSTANTE; } if(kilometer>=(3600*24*LICHTKONSTANTE)) { lichttage = kilometer / (3600*24*LICHTKONSTANTE); kilometer = kilometer - lichttage*3600*24*LICHTKONSTANTE; } if(kilometer>=(3600*LICHTKONSTANTE)) { lichtstd = kilometer / (3600*LICHTKONSTANTE); kilometer = kilometer - lichtstd*3600*LICHTKONSTANTE; } if(kilometer>=(60*LICHTKONSTANTE)) { lichtmin = kilometer / (60*LICHTKONSTANTE); kilometer = kilometer - lichtmin*60*LICHTKONSTANTE; } if(kilometer>0) lichtsek = kilometer / LICHTKONSTANTE; else kilometer = 0; printf("\nThe given distance equals\n%u lightyears\n", lichtjahre); printf("%u lightmonths\n", lichtmonate); printf("%u lightweeks\n", lichtwochen); printf("%u lightdays\n", lichttage); printf("%u lighthours\n", lichtstd); printf("%u lightminutes\n", lichtmin); printf("%lf lightseconds\n", lichtsek); return 0; } /*-----------------------------------------------------------------------------------------*/ /* Function: zeit kmlicht1(double) */ /* responsibility: This function takes a value, lightyears, from planetausgabe() */ /* and returns kilometres converted into */ /* lighthours, -minutes and -seconds to planetausgabe(). */ /* Solar system planets are too near to use larger measures. */ /* The global constant value LICHTKONSTANTE is used in the conversion. */ /* Parameter: double planeteingabe */ /* return: an instance of the global structure zeit to planetausgabe() */ /* with its 3 elements lichtstunden, lichtminuten and lichtsekunden */ /*-----------------------------------------------------------------------------------------*/ zeit kmlicht1(double planeteingabe) { zeit lichtzeit = {0, 0, 0.0}; if(planeteingabe>=(3600*LICHTKONSTANTE)) { lichtzeit.lichtstunden = planeteingabe / (3600*LICHTKONSTANTE); planeteingabe = planeteingabe - (lichtzeit.lichtstunden*3600*LICHTKONSTANTE); } if(planeteingabe>=(60*LICHTKONSTANTE)) { lichtzeit.lichtminuten = planeteingabe / (60*LICHTKONSTANTE); planeteingabe = planeteingabe - (lichtzeit.lichtminuten*60*LICHTKONSTANTE); } lichtzeit.lichtsekunden = planeteingabe / LICHTKONSTANTE; return lichtzeit; } /*--------------------------------------------------------------------*/ /* Function: numeriktest(int test) */ /* responsibility: This function is conducting a numbertest and */ /* returns the tested value to the calling function */ /* Parameter: int test */ /* return: int */ /*--------------------------------------------------------------------*/ int numeriktest(int test) { /*int i; if(test != '-' && test != '+' && !isdigit(test) && test != EOF) { ungetc(test, stdin); printf("\nDie Eingabe muss eine Ganzzahl aus dem Menue sein!\a\n"); return 0; } for(i=0; isdigit(test); test = getchar()) i = 10*i+(test - '\0'); if(test != EOF) ungetc(test, stdin); test = i;*/ return test; } /*-----------------------------------------------------------------------------*/ /* Function: stars() */ /* responsibility: draws a 53 line of 53 asterisks */ /* return: 0 to calling function */ /*-----------------------------------------------------------------------------*/ int stars() { int b=0; for(b;b<=53;b++) { printf("*"); } return 0; } /*-----------------------------------------------------------------------------*/ /* Function: line() */ /* responsibility: draws a line of 53 equals signs */ /* */ /* return: 0 to calling function */ /*-----------------------------------------------------------------------------*/ int line() { int c=0; for(c;c<=53;c++) { printf("="); } printf("\n"); return 0; }