Program not working correctly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • puterialia90
    New Member
    • Jul 2010
    • 2

    #1

    Program not working correctly

    My c++ program does not work.. Can anyone help repair my code?
    The position of a ball falling in the air is given by equation
    X =x0 + v0t + 0.5at2
    X= position after the ball accelerates for a time t
    X0= initial position
    V0=initial velocity
    a= acceleration = -9.81meter/second (a constant)
    t = time
    1) Write the statement including a loop, to generate a table of positions using the position function. Ask the user to enter values for the initial position, x0, and initial velocity, v0. The table should start at 0.0 seconds and use 0.2 second increments up to and including 5.0 seconds. For the table, format the time and position values to have 2 numbers after the decimal point. Provide labels for the columns so the table looks like this for x0=100.0 meters and v0=15.0 meters/second:

    Time Position
    0.00 100.00
    0.20 102.80



    Additional Details
    my source code..

    Code:
    #include <iostream>
    using namespace std;
    
    double position ( double x, double x0, double v0, double a, double t)
    
    double x ( double x0, double v0. double t)
    {
    int main()
    double a=-9.81, t
    
    cout << Enter value between 0.0 and 5.0;
    cin >> t;
    
    {if (t<0)
    cout << " re-enter for a new value";
    cin >> t;
    
    else
    
    cout << "continue";
    cin >> t;
    
    return x =x0 + v0*t +((0.5)*a*t*t)
    Last edited by Banfa; Jul 15 '10, 08:49 AM. Reason: Added [code]...[/code] tags
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    "My c++ program does not work."
    Please elaborate. Are there compiler warnings? Are there run-time errors? Does the program run but yield the wrong answers?

    Comment

    Working...