Velocity code

#include <math.h>
#include <stdio.h>

int main(void)
{
  /*  declare variables */
  double Velocity,acceleration, t_s;
  printf("Input time elapsed in seconds:\n");
  scanf("%lf",&t_s);
  /*  calculations to find Velocity*/
  Velocity = .00001*(t_s*t_s*t_s)-.00488*(t_s*t_s)+.75795*(t_s)+181.3566;
  acceleration = 3-.000062*(Velocity*Velocity);
  printf("Velocity:%lf m/s\n", Velocity);
  printf("Acceleration: %lf m/s^2 \n",acceleration);
 return 0;
}

problem 1)
gcc version 4.6.3
 
Input time elapsed in seconds:
 56
Velocity:210.254280 m/s
Acceleration: 0.259175 m/s/s

problem 2)
  gcc version 4.6.3
 
Input time elapsed in seconds:
 25
Velocity:197.411600 m/s
Acceleration: 0.583777 m/s^2

problem3)
#include <math.h>
#include <stdio.h>

int main(void)
{
  /*  declare variables */
  double Velocity,acceleration, t_s,t_m;
  printf("Input time elapsed in minutes:\n");
  scanf("%lf",&t_m);
  /*  calculations to find Velocity*/
  t_s = t_m*60;
  /* why doesn't t_m = t_s/60 work? */
  Velocity = .00001*(t_s*t_s*t_s)-.00488*(t_s*t_s)+.75795*(t_s)+181.3566;
  acceleration = 3-.000062*(Velocity*Velocity);
  printf("Velocity:%lf m/min\n", Velocity);
  printf("Acceleration: %lf m/min.^2\n",acceleration);
 return 0;
}

gcc version 4.6.3
 
Input time elapsed in minutes:
 .41666
Velocity:197.411387 m/s
Acceleration: 0.583782 m/s^2

problem 4)

#include <math.h>
#include <stdio.h>

int main(void)
{
  /*  declare variables */
  double Velocity,acceleration, t_s,t_m,Velocity_feet,acceleration_feet;
  printf("Input time elapsed in seconds:\n");
  scanf("%lf",&t_s);
  /*  calculations to find Velocity*/
  /* why doesn't t_m = t_s/60 work? */
  Velocity = .00001*(t_s*t_s*t_s)-.00488*(t_s*t_s)+.75795*(t_s)+181.3566;
  Velocity_feet = Velocity*3.2808333;
  acceleration = 3-.000062*(Velocity*Velocity);
  acceleration_feet = acceleration*3.2808333;
  printf("Velocity:%lf feet/s\n", Velocity_feet);
  printf("Acceleration: %lf feet/s^2\n",acceleration_feet);
 return 0;
}
 

Comments

Popular posts from this blog

Day_13

Day 18 WH