Wednesday, January 21, 2009

Phunky Physics

So I spent the better part of this afternoon devising a small program very similar to my algebraic one. This program will take a falling object's initial velocity, elapsed time of descent (or ascent, for it can work either way), and acceleration and it will give you the distance traveled by that object. Modeled in the equation d = v0t+1/2at2

Here's the source code:


#include <>
using namespace std;
// This program is a demonstration of the physics formula relating distance traveled
// acceleration
// and time traveled. Users will input variables and be able to find out the distance traveled, given
// the time traveled, and acceleration.
// Global variables assigned for ease of use in the two functions
float t; // time elapsed
float v0; // starting velocity
float a; // Acceleration (generally 9.8, earth's gravity)
float calculations(float t, float v0, float a);


int main()
{

cout << "Please enter the time elapsed.\n"; cin >> t;
cout << "Please enter the starting velocity.\n"; cin >> v0;
cout << "Please enter the acceleration.\n"; cin >> a;
cout<< "The distance is " << first =" v0" t =" t*t;" second =" a">



As the last few comments note, I will be adding to this sometime soon. (I hope). It could be fairly useful in the future for my Physics courses (I won't be taking any real courses for at least until next year. I just enjoy reading my self-teaching physics book from time to time).

However, I am proud of myself for this one.

Also, on a side note, I added a slight bit of CSS to my myspace page. It just changed the color of the text of a header I added, but it's a step in the right direction!

No comments:

Post a Comment