Having some trouble
Apr 14, 2013 at 2:22pm UTC
code computes but I am not able to enter for my y velocity when I run the code.
also how do I create space between the lines so that when i run there are spaces between what i enter and the actual results? for example to when you space between new paragraghs when writing an essay.
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
#include <iostream>
using namespace std;
int main()
{
const double Y_ACC = -9.81;
const double X_ACC = 0;
int t = 0;
int t1 = 1;
int t2 = 2;
int t3 = 3;
int t4 = 4;
cout << "What is the initial x position?" ;
int x_init = 0;
cin >> x_init;
cout << "What is the initial y position?" ;
int y_init = 0;
cin >> y_init;
cout << "What is the initial x velocity?" ;
int x_vel = 0;
cin >> x_vel;
cout << "What is the initial y velocity?" ;
int y_vel = 0;
cin >> y_vel;
int y_pos = y_init + (y_vel * t) + 0.5 * (Y_ACC * t * t);
int x_pos = x_init + (x_vel * t) + 0.5 * (X_ACC * t * t);
int y_pos1 = y_init + (y_vel * t1) + 0.5 * (Y_ACC * t1 * t1);
int x_pos1 = x_init + (x_vel * t1) + 0.5 * (X_ACC * t1 * t1);
int y_pos2 = y_init + (y_vel * t2) + 0.5 * (Y_ACC * t2 * t2);
int x_pos2 = x_init + (x_vel * t2) + 0.5 * (X_ACC * t2 * t2);
int y_pos3 = y_init + (y_vel * t3) + 0.5 * (Y_ACC * t3 * t3);
int x_pos3 = x_init + (x_vel * t3) + 0.5 * (X_ACC * t3 * t3);
int y_pos4 = y_init + (y_vel * t4) + 0.5 * (Y_ACC * t4 * t4);
int x_pos4 = x_init + (x_vel * t4) + 0.5 * (X_ACC * t4 * t4);
cout << "Position after 0 second(s) is" << "(" << x_pos << "," << y_pos << ")" << "\n" ;
cout << "Position after 1 second(s) is" << "(" << x_pos1 << "," << y_pos1 << ")" << "\n" ;
cout << "Position after 2 second(s) is" << "(" << x_pos2 << "," << y_pos2 << ")" << "\n" ;
cout << "Position after 3 second(s) is" << "(" << x_pos3 << "," << y_pos3 << ")" << "\n" ;
cout << "Position after 4 second(s) is" << "(" << x_pos4 << "," << y_pos4 << ")" << "\n" ;
system ("pause" );
return 0;
Last edited on Apr 14, 2013 at 2:25pm UTC
Apr 14, 2013 at 3:04pm UTC
ok so I think I resolved my issue. programm computed when I changed the x velocity I was entering (1.3) to a whole number, that aloowed me to enter my y velocity
Topic archived. No new replies allowed.