Energy – mass Converter program c++ (cpp) source

This is a Simple C++ code for a converter program that converts energy into mass according to the famous equation from greatest scientist Albert Einstein. E= MC2
Input energy in MeV( Mega electron volt), GeV( Giga electron volt) or inĀ  Tev( Tera electron volt).
You can use visual c++ compiler for compiling and running program. You can find the Source code below. if you are using Borland turbo C++ don’t use “usingĀ namespace std;” and insert .h extension for iostream, iomanip header files. Moreover, it will not supportĀ Ā “system(“CLS”);” and replace it by “clrscr();”
Ā 
E= MC2: –
E = Energy
M = Mass
C = speed of light inĀ vacuumĀ (299792458 m/s)
Let’s imagine the practical use of this equation. Consider just a stone, whichĀ weigh 250g. If you convert it completely into energy, then the total energy from the mass;
E = 0.250(kg) x 89875517873681764 (c x c)
Ā  Ā = 22468879468420441 J
#include<iostream>
#include<Windows.h>//for_sleep()
#include<iomanip>
#include<process.h>Ā  //for_exit()_function;
#include<conio.h>
Ā Ā Ā  using namespacestd;Ā 
void main()
{Ā Ā  system(“color f1”);Ā Ā  //making_colour_combinations
Ā Ā Ā Ā Ā Ā  double consteV=1.60219e-19;
Ā Ā Ā Ā Ā Ā  double constc2=9*10e16;Ā Ā  //c^2;
Ā Ā Ā Ā Ā Ā  int ch;Ā Ā  //for_input
Ā Ā Ā Ā Ā Ā  double e, mass;
Ā Ā Ā Ā Ā Ā  start:Ā Ā Ā  //For_returning_into_main_menu
Ā Ā Ā  system(“CLS”);
Ā Ā Ā Ā Ā Ā  cout<<“tt***********************************************n”;
Ā Ā Ā Ā Ā Ā  cout<<“ttĀ Ā  ENERGY – MASS CONVERTER : UNIT CHOICE MENUn”;
Ā Ā Ā Ā Ā Ā  cout<<“tt***********************************************n”;
Ā Ā Ā Ā Ā Ā  cout<<“nn 1. MeV (Mega Electrone Volts)n 2. GeV (Giga electrone volts)n 3. TeV (Tera Electrone Volts) n 4. Exit”;
Ā Ā Ā Ā Ā Ā  cout<<“nn Please Enter Your Choice :”;
Ā Ā Ā Ā Ā Ā  cin>>ch;
Ā Ā Ā Ā Ā Ā  system(“CLS”);Ā Ā Ā  //Clear_screen_command
Ā Ā Ā Ā Ā Ā  switch(ch)
Ā Ā Ā Ā Ā Ā  Ā {
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  case 1:
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā cout<<“nttĀ Ā Ā Ā  ENERGY-MASS CONVERTER ( E = mc^2 )”;
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā cout<<“nnnnPlease enter energy in MeV :”;
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā cin>>e;
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā e=e*10e6*eV;Ā Ā Ā Ā Ā Ā Ā Ā Ā  // Energy Converted into Joules
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā mass=e/c2;
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā cout<<“nnntttMass = “<<setprecision(10)<<mass<<” Kilograms”;
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Ā  break;
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  case 2:
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  cout<<“tttENERGY-MASS CONVERTER ( E = mc^2 )”;
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  cout<<“nnnnPlease enter energy in GeV :”;
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  cin>>e;
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  e=e*10e9*eV;Ā Ā Ā Ā Ā Ā Ā Ā Ā  // Energy Converted into Joules
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  mass=e/c2;
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  cout<<“nnntttMass = “<<setprecision(10)<<mass<<” Kilograms”;
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Ā  break;
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  case 3:
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā cout<<“tttENERGY-MASS CONVERTER ( E = mc^2 )”;
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā cout<<“nnnnPlease enter energy in TeV :”;
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā cin>>e;
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā e=e*10e12*eV;Ā Ā Ā Ā Ā Ā Ā Ā Ā  // Energy Converted into Joules
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā mass=e/c2;
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā cout<<“nnntttMass = “<<setprecision(10)<<mass<<” Kilograms”;
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Ā  break;
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  case 4 : system(“CLS”);
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Ā Ā Ā Ā  cout<<“nnttttThank you………..”;
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Ā Sleep(1000);
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Ā exit(0);
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  default: cout<<“naInvalid Choice !….nnPlease Try again.”;
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  break;
Ā Ā Ā Ā Ā Ā  Ā }Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  // End of switch
Ā Ā Ā Ā Ā Ā  if(_getch())Ā Ā Ā Ā Ā Ā  //wait_for_any_input_through_keyboard
Ā Ā Ā Ā Ā Ā  Ā  goto start;
return;
}
____________________________________________________________
Muhammed Afsal Villan is an experienced full-stack developer, specialized in desktop and mobile application development. He also regularly publishes quality tutorials on his YouTube channel named 'Genuine Coder'. He likes to contribute to open-source projects and is always enthusiastic about new technologies.