# Einstine calculator Mark 2

``` #include <stdio.h> #include <stdlib.h> #include <math.h> /* Author :A.Mac Hugh Date: 31-8-2003 Version:1.1 beta*/ void engery ();        /* function  */ void lenght (); void time_1 ();      /*  prototypes*/ void momentum (); void mass (); void Kenetic_Eng (); void st(); #define c 3E8 int main() { int menu (); /* function prototype*/     printf("\n\tWelcome to Machsofts Einstine calculator.\n"       "\tThis program will \n\t "       "calculate all of the equatios for Einstines Theroy of Special General Relativity.");         printf("\n\tThis is copyright Machsoft INC 2002");         printf("\n\tVersion 1.1 Beta\n\n\n");/* intoduction*/                 menu (); /*fuction beging run*/ return menu(); } int menu (){ int nums; /* ask user for therir option*/   printf("\n\n\n");   printf("\n\n\nSlect from 1-0 and  hit enter after  choice\n\n");   printf("\t\tTo calculate Engery  press \t\t\t(1)\n");   printf("\t\tTo calculate Lenght contraction press \t\t(2)\n");   printf("\t\tTo calculate Time dialation press \t\t(3)\n");   printf("\t\tTo calculate Relativistic Momentum \t\t(4)\n");   printf("\t\tTo calculate Relarive Mass  press \t\t(5)\n");   printf("\t\tTo calculate Kenetic Engery \t\t\t(6)\n");   printf("\n\t\t\tTo exit  press (0) then enter\n"); scanf("%d",& nums);/*get option*/  /*Switich statment for chosesing option*/ switch (nums){       case 0:       exit(0);       break;       case 1 :       engery();       printf("\n\n)");       break;       case 2:       lenght();       printf("\n\n)");       break;       case 3:       time_1();       printf("\n\n)");       break;       case 4:       momentum();       printf("\n\n)");       break;       case 5:       mass();       printf("\n\n)");       break;       case 6:       Kenetic_Eng();       printf("\n\n)");       break;       case 1701:       st();       printf("\n\n)");       break;       default:/*invalid option*/       printf("\aInvaiid Option \n\nEnter choice again \n\n");       printf("\n\n\n");       break;             }    } /* Fuction name :engery   Fuction varibles( All floats) : e engery                                 m mass                                   Purpose: Ask user to enter in the mass.Works out the engery . Prints out engery in joules*/ void engery (){    float e; float m;     printf("This works out Mister Einstein most famous equation E=MC squared\n\nE=Engery\n\nM=Mass\n\n C = The speed of light\n\n");     printf(" Please enter in the values for the mass (m)\nand press enter\n\n" );/*ask user enter in values*/     scanf("%f",&m);/* get values*/     e=c*c*m;     printf("\nThe Engery is %e joules \n\t\n",e);/* prints out engery*/ }  /* Fuction name :lenght   Fuction varibles( All doubles) : l_0 orignal lenght                                                 l_1 lenght                                                 v velocity Purpose: Ask user to enter in the orignal lenght and velocity.Works out lenght. Prints out lenght*/ void lenght (){    float l_0 ; float l_1; float v;         printf("This works Lenght contraction equation\n\n ");         printf(" Please enter in the values for \nthe orgnal lenght and the velocity \nPress enter after each value\n \n");/*ask user enter in values*/         scanf("%f%f",&l_0,&v);/* get values*/     l_1=l_0*sqrt(1-(v*v)/(c*c));     printf("\nThe lenght is %e meters\n\t\n",l_1);/* prints out lenght */ } /* Fuction name :time   Fuction varibles( All floats) : t_0 time at rest                                 t time                                                                 v velocity                                                                                                       Purpose: Ask user to enter in the time at rest.Works out works time. Prints out time*/ void time_1 (){ float t ; float t_1; float v;         printf("This works Time dialation equation\n\n ");         printf(" Please enter in the values for\n the time at rest and the velocity.\nPressenter after each vaule\n\n");/*ask user enter in values*/         scanf("%f%f",&t_1,&v);/* get values*/     t=t_1/sqrt(1-(v*v)/(c*c));     printf("\n\n\n\n\n\n\nThe time is %e seconds\n\t\n",t);/* prints out time */ } /* Fuction name :momentum   Fuction varibles( All floats) :  m_0 orignal mass                                 p  momentum                                                                 v velocity                                                                                                       Purpose: Ask user to enter in the ogrignal mass and velocity.Works out works momentum. Prints out momentum*/ void momentum (){ float p ; float m_0; float v;         printf("This works  equation Relativistic Momentum\n\n");         printf(" Please enter in the values \nfor the orignal mass and the velocity \nPress enter after each value\n\n");/*ask user enter in values*/         scanf("%f%f",&m_0,&v);/* get values*/         p=(m_0)*(v)/sqrt(1-(v*v)/(c*c));     printf("\nThe momentum is %e\n\t\n",p);/* prints out momentum*/ } /* Fuction name :Kenetic_Eng   Fuction varibles( All floats) :  m_0 ogrignal mas                                 v velocity                                                                 ke kentic_Eng                                                                                                       Purpose: Ask user to entert in the ogrignal mass and velocity.Works out works kentic engery. Prints out Kentic engery*/ void Kenetic_Eng (){ float ke ; float m_0; float v;         printf("This works  Kenetic Engery equation");         printf(" Please enter in the values for \nthe orignal mass and the velocity \n Press enter after each value\n");/*ask user enter in values*/         scanf("%f%f",&m_0,&v);/* get values*/         ke=(m_0)*(c)*sqrt(1-(v*v)/(c*c));     printf("\nThe Kenetic Engery is %e\n\t\n",ke);/* prints out KE*/ } /* Fuction name :mass   Fuction varibles( floats) :      m_0 ogrignal mas                                 v velocity                                                                 m kentic_Eng                                                                                                       Purpose: Ask user to entert in the ogrignal mass and velocity.Works out works mass. Prints out mass*/ void mass (){ float m; float m_0; float v;       printf("This works Relarive Mass equation\n\n ");       printf(" Please enter in the values \nfor the orignal mass  and the velocity \nPress enter after each value\n\n");/*ask user enter in values*/       scanf("%f%f",&m_0,&v);/* get values*/       m=(m_0)/sqrt(1-(v*v)/(c*c));       printf("\nThe momentum is %e \n\n\n",m);/* prints out mass*/   }   /*Ester Egg fuction*/ void st(){     printf( "\n\nUSS ENTERPRISE NCC-1701-E\n\n\n LAUNCHED IN 2372\n\n\nCO CAPTIAN JEAN -LUC PICARD\n\n\n XO  CRMD.WILLIAM T RIKER\n\n\n 2ND XO LT.CRMD DATA\n\n\n");                                 /*prints out ester egg.What do you think???????*/     }```