Appendix 2
//team 12
//James Hill, Jason Reyes, Ben Wheatley, and Will Howard
//AiS program
//Libraries
#include<iostream.h>
#include<math.h>
#include<fstream.h>
/*****************************Main************************/
void main ()
{ //opening main
ofstream outfile ("everything.dat"); //Our datafile.
//declaring variables
float M, MA, VM, VA, G, F, EA, T, HB, m1, v1, m2, v2, AF, t;
const double pi=3.1416;
for (m1=188; m1<=248; m1+=20)
{//opening mass for loop
for (v1=5; v1<=65; v1+=10)
{//opening velocity for loop
{//opening velocity for loop
m2=m1;
//mass of Asteroid
v2=0;
//velocity after collision is a complete stop
t=0.5;
//time of impact
AF=((m1*v1)-(m2*v2))/t;
//AF=the force given off by the asteroid
EA=m1*(pow((v1*1000),2))/2;
//Formula for the kinetic energy of the asteroid in joules.
// m1 - the mass of the asteroid.
// v1 - is the velocity of the asteroid entered.
// v1 is multiplied by 1000 to convert from kilometers to meters.
// v1 - is the velocity of the asteroid entered.
// v1 is multiplied by 1000 to convert from kilometers to meters.
T=AF+EA;
//Formula for the total energy given off by the asteroid in joules.
// EA is the kinetic energy given off by the asteroid.
// AF is the force given off by the asteroid.
HB=(T)/(4.186*(pow(10,9)))*20000;
// T - is the total energy released from the collision.
// 4.186^9 is the number of Joules in a ton of TNT.
// 20,000 Tons of TNT is equal to 1 Hiroshima Bomb.
outfile<<"EA= "<<EA<<" "<<"T= "<<T<<" "<<"HB= "<<HB<<" "<<"AF=
"<<AF<<endl;
//outfile for all data.
} //closing velocity for loop
} //closing mass for loop
} //closing velocity for loop
} //closing mass for loop
G=6.673*(pow(10,-8));
//The gravitational constant
F=G*(6.4185*(pow(10,23)))/(pow(3397,2));
outfile<<"The Gravitational Force in Mars is "<<F<<endl;
M=6.4185*(pow(10,23))*24.2;
//Formula for the momentum of Mars.
// 6.4185*10^23 kg is the mass of Mars.
// 24.2 km/sec is the velocity of Mars.
cout<<"The momentum of Mars is "<<M<<endl;
MA=m1*v1;
//Formula for the momentum of the asteroid.
// m1 - mass of asteroid
// v1 - is the speed of the asteroid inputed.
// m1 - mass of asteroid
// v1 - is the speed of the asteroid inputed.
cout<<"The momentum of the asteroid is "<<MA<<endl;
VM=4.0/3.0*pi*(pow(3397,3));
//Formula for the volume of Mars.
// 4/3pi*radius^3 gives the volume of a spherical object.
// 3397 km is the radius of Mars from the center to the equator.
cout<<"The volume of Mars is "<<VM<<endl;
VA=4.0/3.0*pi*(pow(659,3));
//Formula for the volume of the Asteroid.
// 4/3pi*radius^3 gives the volume of a sphereical shape.
// 659 km is the radius of the asteroid that we selcted.
cout<<"The volume of the asteroid is "<<VA<<endl;
cout<<"You can view the rest of the data at 'pico everything.dat'."<<endl;
} //closing main