------- I want to program with struct in C++ ------------------ In this workshop
ID: 3625041 • Letter: #
Question
------- I want to program with struct in C++ ------------------
In this workshop, you are to write a program that uses one or more derived types. Select one problem, solve that problem, and submit your solution to cms.
You know that the height (in m) of a projectile is given by the formula
h = - g * t^2 / 2 + b * t
where t is the time from launch, g is the acceleration due to gravity (9.8 m/sec^2) and b is the initial vertical velocity component (in m/sec).
Design and code a program that calculates the time at which a projectile will reach a certain height. Your program prompts for and accepts the initial vertical velocity component and the desired height. Your program handles cases where the desired height is the maximum height reached and the desired height is never attained.
The output from your program might look something like:
Fireworks
=========
Initial vertical velocity (m/sec): 20
Desired Height (m): 10
Your firework will reach the desired height at times:
0.58 sec
3.50 sec
Explanation / Answer
/* There are three separate files This is main.cpp */ #include #include "CFirework.h" #include int main (int argc, char * const argv[]) { double initialVel = 0; double desiredHeight = 0; std::cout > initialVel; std::cout > desiredHeight; CFirework *firework = new CFirework(); firework->SetVelocity(initialVel); firework->SetHeight(desiredHeight); firework->SetTimes(); std::vector times = firework->GetTimes(); std::coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.