A little help with a project please...

Discussion in 'Programming General' started by Chase, Sep 18, 2011.

A little help with a project please...
  1. Unread #1 - Sep 18, 2011 at 12:18 PM
  2. Chase
    Joined:
    Mar 8, 2006
    Posts:
    1,858
    Referrals:
    6
    Sythe Gold:
    11

    Chase Whore
    Retired Global Moderator

    A little help with a project please...

    I know how to do the language itself, just a little problem with the equations. What are the integer/floats i should specify, and how should i go about doing the equations? I'm stuck, as this is really stumping my mind about how to do it.
     
  3. Unread #2 - Sep 18, 2011 at 1:24 PM
  4. BotsInc
    Joined:
    Aug 12, 2011
    Posts:
    78
    Referrals:
    0
    Sythe Gold:
    0

    BotsInc Member

    A little help with a project please...

    I happen to be a physicist by profession. If you have any questions, then feel free to send a PM my way.

    Code:
    #include <iostream>
    #include <math.h>
    
    using namespace std;
    
    int main()
    {
         //Variables
        double acceleration = 9.8;
        double velocity_final = 0;
        double velocity_initial = 0;
        double distance = 0;
        double height_of_floor = 0;
        double time = 0;
        int number_of_floors = 0;
    
        //Initialize data
        cout << "How many floors in the building?" << endl;
        cin >> number_of_floors;
    
        cout << "What is the height of a floor?" << endl;
        cin >> height_of_floor;
    
    
        //Any item with no air resistance will drop at a constant 9.8 meters per second times second.
        //So if we know the distance of the fall then we can compute the time by setting both equations
        //equal to each-other as we already know the acceleration!
    
        //Distance is number_of_floors times height_of_floor
        //acceleration = (velocity_final - 0) / time so that we get:
        //acceleration = velocity_final / time which means that:
        //velocity_final = acceleration*time
        distance = number_of_floors*height_of_floor;
        time = sqrtf(2*distance/acceleration);
        velocity_final = acceleration*time;
    
        cout << "The balloon takes " << time << " s to hit the floor." << endl;
        cout << "The final velocity of the balloon is " << velocity_final << " m/s." << endl;
    
    
    
        return 0;
    }
    
    
     
  5. Unread #3 - Sep 18, 2011 at 1:46 PM
  6. BotsInc
    Joined:
    Aug 12, 2011
    Posts:
    78
    Referrals:
    0
    Sythe Gold:
    0

    BotsInc Member

    A little help with a project please...

    [​IMG]
    [​IMG]
     
  7. Unread #4 - Sep 20, 2011 at 6:25 PM
  8. Chase
    Joined:
    Mar 8, 2006
    Posts:
    1,858
    Referrals:
    6
    Sythe Gold:
    11

    Chase Whore
    Retired Global Moderator

    A little help with a project please...

    Thanks so much, I got it down. By looking at your source I figured out what I had to do and used printf to do it instead. Thank you, you got me an A on the project, haha. If I have any problems, you'll be the first I come too.
     
< What's a good way to learn web design? | Minion IRC Bot: Open Source >

Users viewing this thread
1 guest


 
 
Adblock breaks this site