I recently got an assignment from my pressor that ask me to Write a program that computes the duration of a projectile’s flight and its height above the ground when it reaches the target.

He gave us the following equations to work with:

a. time = distance/ velocity x cos(0)

b. height = velocity x sin(0) x time - (g x time^2)/2

distance, velocity, and angle are all inputs from the user and g is a gravitational consistency of 32.17

/*

Name: Erik Diaz

Course : Computer science and programming

Section : 07

Date : 09 / 23 / 2020

ID:lab 5b

Purpose:

Write a program that computes the duration of a projectile’s flight and its height above the ground when it reaches the target.

Analysis/ Data:

1. inputs: angle, distance, velocity (float)

2. output: time in seconds, height (float)

3. equations

a. time = distance/ velocity x cos(0)

b. height = velocity x sin(0) x time - (g x time^2)/2

Typical-

input:

expected output:

Results:

Boundry-

input:

expected output:

results:

Extreme-

input:

expected output:

results:

*/

#include <iostream>

#include <cmath>

using namespace std;

float velocity, target_distance, angle;

float grav_const = 32.17;

float inPuts( ) {

cout << "please enter the velocity of the projectile: ";

cin >> velocity;

cout << "it's distance: ";

cin >> target_distance;

cout << "The angle: ";

cin >> angle;

return velocity, target_distance, angle;

}

float time ( ) {

inPuts( );

return target_distance/ velocity * cos(angle);//equation for time

}

float height() {

inPuts();

time();

float height1 = velocity * sin(angle) * time() - (grav_const * (time() * time())) / 2;//equation for height

return height1;

}

int main() {

cout << time() << endl << height();

}

I'm using a different ide so I'm not sure if I copied and pasted correctly.

I keep getting consistent numbers when I input numbers yet they are wrong (ex: 1, 1, 1 for the inputs ->.54 for output or time). Also, the code consistently repeats 5 times yet I have no loops. I was tight for time so I only tested to see if the computer ran through each function.