Submitted by: Submitted by fated
Views: 185
Words: 372
Pages: 2
Category: Science and Technology
Date Submitted: 08/06/2012 05:33 AM
#include
#define gravity 9.81
float calcMomentum(float mass, float velocity) //function containing variable velocity and mass
{
return mass * velocity; // return the produt of ( mass * velocity )
}
float calcWork(float force, float distance)
{
return force * distance;
}
float calcKinEnergy(float mass, float velocity)
{
return ((mass/2)*(velocity*velocity));
}
float calcPotentialEnergy(float mass, float height)
{
return ( mass * gravity * height );
}
float calcThermodynamic(float heat_supplied, float work_bygas)
{
return ( heat_supplied - work_bygas );
}
void Menu(void)
{
printf("Which option do you want?\n");
printf("1. Momentum \n");
printf("2. Energy \n");
printf("3. Work \n");
}
int main ()
{
char option,choice;
float mass = 0, velocity = 0, distance = 0, force = 0, heat_supplied = 0, height = 0, work_bygas = 0;
printf("Which option do you want?\n");
printf("1. Momentum \n");
printf("2. Energy \n");
printf("3. Work \n");
scanf("%c", &option);
switch(option)
{
case '1':
printf("Enter mass of the object (kg): ");
scanf("%f", &mass);
printf("Enter the velocity of the object (m/s): ");
scanf("%f", &velocity);
printf("The momentum of the object is %.2f (kg*m)/s", calcMomentum(mass,velocity));
break;
case '2':
printf("Choose an energy: \n");
printf("1.Kinetic Energy\n");
printf("2.Potential Energy\n");
printf("3.Thermodyanmic Energy\n");
scanf("%c", &choice);
if ( choice == 1 )
{
printf("Enter the mass of the object travelling (kg): ");
scanf("%f", &mass);
printf("Enter the velocity of the object (m/s): ");
scanf("%f", &velocity);
printf("The kinetic energy of the object is %.2f...