Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Need help fast C++


ghost's Avatar
0 0

This is solving motion of physics… and for the intal speed i cant use 0 and i need to be able to.. i need to know how i can use a NULL so it solves for infomation that is not there. i used 0 not think but i cant figure it out…..ty for ur time

#include <iostream>
#include <string>
using namespace std;
string physicsnow(double v,double t,double d,double a,double dv) 
{
     cout <<"\n\n\n";
     cout <<"~~Thinking cause ur to lazy to~~" << "\n\n";
       
       int null=0; // use 0 as a variable.
              
       if(v==null) // speed
       {
        v=d/t;   
           }
       if(t==null) // time
       {
        t=d/v;   
           }
       if(d==null) //distance
       {
        d=t*v;   
           }
       if(a==null) //acceleration
       {
        a=dv/t;   
           }
       if(dv==null) //detlav
       {
        dv=a*t;   
           }
     cout <<"The Avg speed is: "<< v <<"m/s"<< "\n\n";
     cout <<"The Time is: " << t << "s" << "\n\n";           
     cout <<"The Distance is: " << d << "m" << "\n\n";
     cout <<"The Acceleration is: "<< a << "m/s sqr" << "\n\n";
     cout << "The Change in Speed is: " <<dv<< "m/s" << "\n\n";             
}
int main(int argc, char *argv[])
{
    cout << "\n" << endl; 
    cout << "Thank your For using Motion Physics Calculator By ::zer0pain::"<< "\n" << endl;
    cout << "To report any bugs plz feel free to email me at zer0.crashoveride@gmail.com" <<"\n"<< endl;
    
    double v, t, d, a, vi, vf, dv ;
    
    cout << "Directions:" << "\n" ;
    cout << "For any varibles that u are solving for you must put '0'" << "\n" << endl;
    
    cout <<"Please input speed in meters/second:" ;
    cin >> v;
    
    cout <<"Please input distance in meters:" ;
    cin >> d;
    
    cout <<"Please input time in seconds:" ;
    cin >> t;
    
    cout <<"Please input accerlation in m/s sqr:" ;
    cin >> a;
    
    cout <<"Please input intal speed in m/s:" ;
    cin >> vi;
    
    cout <<"Please input final speed in m/s:" ;
    cin >> vf;
    
    dv=vf-vi;
    
    physicsnow(v, t, d, a, dv);
    
    system("PAUSE");
    return EXIT_SUCCESS;
}

ghost's Avatar
0 0

I know absolutely nothing about physics but… I tested your program and it worked fine for me. What was your output when you tried to use 0 as your initial speed? This is what I got when I used your program. Everything seems good.


Thank your For using Motion Physics Calculator By ::zer0pain::

To report any bugs plz feel free to email me at zer0.crashoveride@gmail.com

Directions:
For any varibles that u are solving for you must put '0'

Please input speed in meters/second:30
Please input distance in meters:500
Please input time in seconds:20
Please input accerlation in m/s sqr:12
Please input intal speed in m/s:0
Please input final speed in m/s:10



~~Thinking cause ur to lazy to~~

The Avg speed is: 30m/s

The Time is: 20s

The Distance is: 500m

The Acceleration is: 12m/s sqr

The Change in Speed is: 10m/s

Press any key to continue . . .


ghost's Avatar
0 0

see u solved for vi i need to have vi ans a value of 0 like the car starts at 0 and accelerats to 60km/h


ghost's Avatar
0 0

I also found that instead of using your int defined null variable, you could use NULL and everything appears to work fine. Just less work for you.


ghost's Avatar
0 0

zer0pain1337 wrote: see u solved for vi i need to have vi ans a value of 0 like the car starts at 0 and accelerats to 60km/h

Can you give me a case in which it doesn't work? Give me the variable's you had when it didn't work.


ghost's Avatar
0 0

o i think i got it. the way i set it up i kinda fixes its self cause each if has can set a var. and it solves for vi every time cause u put 0. if u dont have the info to solve for it so leave the last 3 as 0's


ghost's Avatar
0 0

omg it solves it every time i cant thing of var that wont solve 4 it so in a way that is good but… i want the user to be able to put in nulls and not using int values. since im dealing with #s ya know…