Simple Program: output problem

Hi,

I am writing a video game and I was trying to model a SUVAT equation in basic code before I use it in more complicated stuff. The code I'm using is relatively simple but I'm getting wierd outpus. It might just be my complier or my cimputer but heres is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>

using namespace std;

struct XMFloat3
{
    float x;
    float y;
    float z;
};

int main()
{
    //cout << "Hello world!" << endl;

    XMFloat3 input;
    XMFloat3 aim;
    XMFloat3 final;

    int velocity;
    int time;
    int acceleration;
    float gradient;

    float yChange;
    float xChange;
    //float zChange;

    cout << "Please input the starting x co-ordinates: " << endl;
    cin >> input.x;
    cout << "Please input the starting y co-ordinates: " << endl;
    cin >> input.y;
    cout << "Please input the starting z co-ordinates: " << endl;
    cin >> input.z;

    cout << "Please input the aiming x co-ordinates: " << endl;
    cin >> aim.x;
    cout << "Please input the aiming y co-ordinates: " << endl;
    cin >> aim.y;
    cout << "Please input the aiming z co-ordinates: " << endl;
    cin >> aim.z;

    cout << "Please specify the initial velocity (m/s): " << endl;
    cin >> velocity;

    cout << "Please specify the time passed (s): " << endl;
    cin >> time;

    cout << "Please specify x acceleration: " << endl;
    cin >> acceleration;

    yChange = 0.5 * 9.8 * (time * time); // Change in y = 1/2 9.8 * t squared
    xChange = (velocity * time) + 0.5 * ((acceleration) * (time * time));

    gradient = ((aim.x - input.x)/(aim.z - input.z));


    final.x = input.x + xChange;
    final.y = input.y - (yChange);
    final.z = (input.z + xChange) * gradient;

    //cout << "The final outcome is: " + (int)final.x + " " + (int)final.y + " " + (int)final.z + "." << endl;
    cout << "The final x outcome is: " + (int)final.x << endl;
    cin.get();
    cout << "The final y outcome is: " + (int)final.y << endl;
    cin.get();
    cout << "The final z outcome is: " + (int)final.z << endl;
    cin.get();

    return 0;
}


My inputs were. input.x = 1; input.y = 2; input.z = 3; aim.x = 100; aim.y = 2; aim.z = 102; velocity = 18; time = 3; acceleration = -3;

Thanks in advanced!
Sorry, I just realised. it should be this:

1
2
3
4
5
6
7
 
 cout << "The final x outcome is: " << (int)final.x << endl;
    cin.get();
    cout << "The final y outcome is: " << (int)final.y << endl;
    cin.get();
    cout << "The final z outcome is: " << (int)final.z << endl;
    cin.get();


I feel so dumb! Sorry!
Topic archived. No new replies allowed.