| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
No idea what I'm doing
I have to write a program in C that computes the duration of a projectile's flight and it's height above the ground when it reaches the target.
Problem constant G 32.17 (gravitational constant) Problem Inputs double theta (input angle) double distance (distance to target) double velocity (projectile velocity) Problem outputs double time (time of flight) double height (height at impact) relevant formulas time=distance/ velocity x cos(theta) height= velocity x sin(theta) x time - (g x time^2)/2 That is all of the info given in the book. I have no idea what to do with this info. I could really use some help with this. I know what all of the inputs and equations mean, I just don't know how to program. |
|
#2
|
||||
|
||||
|
Seems rather simple to me.
Use the time formula to determine how long it takes the projectile to get to the target, then use the time value in the height formula to determine what's it's height at the moment of inpact. This is all basic mathematics/physics.
__________________
This is my code. Is it not nifty? "The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools." ---Douglas Adams Join the Itsacon fanclub! Zero Tolerance: Spammers banned so far: 280
![]() |
|
#3
|
|||
|
|||
|
I understand the physics of it and could do it by hand, but I'm doing this for a programming class. It's supposed to be a beginner class, but I think I'm the only one that has never programmed before. I really need help with how to write the program.
|
|
#4
|
|||||
|
|||||
|
Ok, here's a program that does what you want.
I've tried to explain as much as possible what I'm doing, try to learn something from it. cpp Code:
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > No idea what I'm doing |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|