Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PhysicsCalculator For this program we\'ll implement problems 5 and 6 from chapte

ID: 3552676 • Letter: P

Question

PhysicsCalculator

For this program we'll implement problems 5 and 6 from chapter 6. You'll write a single program that will allow a user to either calculate Falling Distance (problem 5) or Kinetic Energy (problem 6). The program will also give a third option where the program will run a "Driver" (or test harness) to test both the Falling Distance and Kinetic Energy functions (much like described in problem 5).

------------------------------------

Here is the link for problem 5 & 6

http://s13.postimg.org/b6rcmbgnr/photo_2.jpg

-----------------------------------

3/14 When you run the program to just calculate either Falling Distance or Kinetic Energy, you will need to ask the user to specify the inputs. When you run the test harness, you'll hard code the range of values that you'll run the functions on. (Sounds like a good use for for loops.)

Explanation / Answer

#include<iostream>

using namespace std ;


#define G 9.8

double fallingDistance(int t)

{

double d ;

d = (double)0.5*t*t*G ;

return d ;

}


double kineticEnergy( double m ,double v )

{

double KE ;

KE = (double)0.5*m*v*v ;

return KE ;

}


void Driver()

{

// Test fallingDistance()

for(int i = 1 ; i <= 10 ; i++ )

{

cout << "For time = " << i << "secs fallingDistance :" ;

cout << fallingDistance(i) << endl ;

}

// Test kineticEnergy() ,mass = 10

for(int i = 1 ; i <= 10 ; i++ )

{

cout << "For velocity = " << i << "m/secs KineticEnergy :" ;

cout << kineticEnergy(10,i) << endl ;

}

}

int main()

{


int choice ;

cout << "choose an option 1. fallingDistance 2. KineticEnergy 3 . Driver() " << endl ;

cin>> choice ;

switch(choice)

{

case 1 : cout << "Enter time" << endl ;

int t;

cin >> t ;

cout << "For time = " << t << "secs fallingDistance :" ;

cout << fallingDistance(t) ;

break ;

case 2 : cout << "Enter mass and velocity " << endl ;

double m , v ;

cin >> m >> v;

cout << "For velocity = " << v << "m/secs KineticEnergy :" ;

cout << kineticEnergy(m,v) << endl ;

break ;

case 3 : Driver() ;


}


return 0 ;

}