1. Analyze the problem below and make a c++ program to enter on the keyboard the required
    data for process. Compute the time of flight of a projectile and its height above the ground
    when it reaches the target. Display all the inputed data and the processed or compute data.
    Use the following givens:
    G 32.17 /is the gravitational acceleration constant in feet per second fps/
    Other Input:
    theta / the angle of aim of the projectile with respect to the horizontal ground when it was
    fired
    /
    distance / distance of from the canon to the target/
    velocity / starting velocity of the projectile in fps/
    Expected Results:
    time / time of flight of the projectile to reach its target/
    height / how high the projectile above the target /
    Useful C formula:
    time = distance / (velocity cos (theta))
    height = velocity
    sin(theta) time – (Gtime*time)/2

Can you show what code you have so far and where you're stuck?

Set up some variables (time, height, theta, distance, velocity), constant (g), user defined functions (time and height) and maths functions (sin, cos) then write the logic.

You have to do some work here. If you attempt something and work on it you will learn much more than someone else doing your homework and you copying it into your assignment and getting a mark that way. Try.

Logic: read input from keyboard, calculate using variables, constant and functions, write output.

There are also C++ online manuals for language syntax to help you. Google C++ language. E.g. https://cplusplus.com/doc/tutorial/. It covers variables, constants and functions.

Use pseudo code then convert it into C++. That's how I learned programming.

This question should be deleted. Person has no intention of working out answer.

Here's a C++ program that calculates the time of flight and height of a projectile based on the provided data and formulas:

#include <iostream>
#include <cmath>

const double G = 32.17;  // Gravitational acceleration constant in feet per second squared (fps^2)

int main() {
    double theta, distance, velocity;

    // Input the data
    std::cout << "Enter the angle of aim (theta in degrees): ";
    std::cin >> theta;
    std::cout << "Enter the distance to the target (in feet): ";
    std::cin >> distance;
    std::cout << "Enter the starting velocity (in fps): ";
    std::cin >> velocity;

    // Convert the angle from degrees to radians
    double thetaRad = theta * M_PI / 180.0;

    // Calculate the time of flight
    double time = distance / (velocity * cos(thetaRad));

    // Calculate the height
    double height = velocity * sin(thetaRad) * time - (G * time * time) / 2.0;

    // Display the input and computed data
    std::cout << "\nInput Data:\n";
    std::cout << "Angle of aim (theta): " << theta << " degrees\n";
    std::cout << "Distance to the target: " << distance << " feet\n";
    std::cout << "Starting velocity: " << velocity << " fps\n";

    std::cout << "\nComputed Data:\n";
    std::cout << "Time of flight: " << time << " seconds\n";
    std::cout << "Height above the ground: " << height << " feet\n";

    return 0;
}

This program takes the angle of aim (in degrees), distance to the target (in feet), and starting velocity (in fps) as input. It then calculates and displays the time of flight and height above the ground when the projectile reaches the target. Make sure to compile and run the program in a C++ development environment.

I don't think it helps you if other people do your homework for you. It's much better if you at least make an attempt and then ask specific questions where you get stuck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.