Day 3 Mods and HW
#1 SALINITY
/*–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––*/
/* This program uses linear interpolation to */
/* compute the freezing temperature of seawater. */
#include <stdio.h>
#include <math.h>
int main(void)
{
/* Declare variables. */
double a, f_a, b, f_b, c, f_c;
/* Get user input from the keyboard. */
printf("Use ppt for salinity values. \n");
printf("Use degrees F for temperatures. \n");
printf("Enter first salinity and freezing temperature: \n");
scanf("%lf %lf",&a,&f_a);
printf("Enter second salinity and freezing temperature: \n");
scanf("%lf %lf",&c,&f_c);
printf("Enter new salinity: \n");
scanf("%lf",&b);
// Use linear interpolation to compute new freezing temperature.
f_b = f_a + (b-a)/(c-a)*(f_c - f_a);
/* Print new freezing temperature. */
printf("New freezing temperature in degrees F: %4.1f \n",f_b);
printf("New freezing temperature in degrees C: %4.1f \n",(f_b - 32)*5/9);
printf("Enter a freezing temp in degrees F: \n");
scanf("%lf",&b);
f_b = ((b-f_a)*(c-a)/(f_c - f_a)) + a;
printf("The salinity in ppt is: %4.1f \n",f_b);
return 0; /* Exit program. */
}
//MOD 3 No the program would not need to be changed the calculations would all just be done in degrees C
#2 PLANES
/*----------------------------------------------------------------------*/
/* Garrett Giordano - Luke Colias */
/* PlaneSpeed */
/* Calculates Plane velocity and acceleration based on time
/*----------------------------------------------------------------------*/
#include <stdio.h>
#include <math.h>
double CalcVel(double);
double CalcAccel(double);
int main(void)
{
/* Declare variables. */
double time, velocity, acceleration;
/* Get user input from the keyboard. */
printf("Input Time in Seconds:");
scanf("%lf",&time);
// Use linear interpolation to compute new freezing temperature.
velocity = CalcVel(time);
acceleration = CalcAccel(velocity);
/* Print new freezing temperature. */
printf("Velocity: %4.2f \n",velocity);
printf("Acceleration: %4.2f \n", acceleration);
printf("Velocity(ft/s): %4.2f \n",velocity*39.37/12);
printf("Acceleration(ft/s): %4.2f \n", acceleration*39.37/12);
printf("Input Time in Minutes:");
scanf("%lf",&time);
time *= 60;
velocity = CalcVel(time);
acceleration = CalcAccel(velocity);
/* Print new freezing temperature. */
printf("Velocity: %4.2f \n",velocity);
printf("Acceleration: %4.2f \n", acceleration);
printf("Velocity(ft/s): %4.2f \n",velocity*39.37/12);
printf("Acceleration(ft/s): %4.2f \n", acceleration*39.37/12);
return 0; /* Exit program. */
}
double CalcVel(double time)
{
return .00001 * pow(time,3) - .00488*pow(time,2) + .75795 * time + 181.3566 ;
}
double CalcAccel(double vel)
{
return 3-.000062 * pow(vel,2);
}
/*–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––*/
/* This program uses linear interpolation to */
/* compute the freezing temperature of seawater. */
#include <stdio.h>
#include <math.h>
int main(void)
{
/* Declare variables. */
double a, f_a, b, f_b, c, f_c;
/* Get user input from the keyboard. */
printf("Use ppt for salinity values. \n");
printf("Use degrees F for temperatures. \n");
printf("Enter first salinity and freezing temperature: \n");
scanf("%lf %lf",&a,&f_a);
printf("Enter second salinity and freezing temperature: \n");
scanf("%lf %lf",&c,&f_c);
printf("Enter new salinity: \n");
scanf("%lf",&b);
// Use linear interpolation to compute new freezing temperature.
f_b = f_a + (b-a)/(c-a)*(f_c - f_a);
/* Print new freezing temperature. */
printf("New freezing temperature in degrees F: %4.1f \n",f_b);
printf("New freezing temperature in degrees C: %4.1f \n",(f_b - 32)*5/9);
printf("Enter a freezing temp in degrees F: \n");
scanf("%lf",&b);
f_b = ((b-f_a)*(c-a)/(f_c - f_a)) + a;
printf("The salinity in ppt is: %4.1f \n",f_b);
return 0; /* Exit program. */
}
//MOD 3 No the program would not need to be changed the calculations would all just be done in degrees C
#2 PLANES
/*----------------------------------------------------------------------*/
/* Garrett Giordano - Luke Colias */
/* PlaneSpeed */
/* Calculates Plane velocity and acceleration based on time
/*----------------------------------------------------------------------*/
#include <stdio.h>
#include <math.h>
double CalcVel(double);
double CalcAccel(double);
int main(void)
{
/* Declare variables. */
double time, velocity, acceleration;
/* Get user input from the keyboard. */
printf("Input Time in Seconds:");
scanf("%lf",&time);
// Use linear interpolation to compute new freezing temperature.
velocity = CalcVel(time);
acceleration = CalcAccel(velocity);
/* Print new freezing temperature. */
printf("Velocity: %4.2f \n",velocity);
printf("Acceleration: %4.2f \n", acceleration);
printf("Velocity(ft/s): %4.2f \n",velocity*39.37/12);
printf("Acceleration(ft/s): %4.2f \n", acceleration*39.37/12);
printf("Input Time in Minutes:");
scanf("%lf",&time);
time *= 60;
velocity = CalcVel(time);
acceleration = CalcAccel(velocity);
/* Print new freezing temperature. */
printf("Velocity: %4.2f \n",velocity);
printf("Acceleration: %4.2f \n", acceleration);
printf("Velocity(ft/s): %4.2f \n",velocity*39.37/12);
printf("Acceleration(ft/s): %4.2f \n", acceleration*39.37/12);
return 0; /* Exit program. */
}
double CalcVel(double time)
{
return .00001 * pow(time,3) - .00488*pow(time,2) + .75795 * time + 181.3566 ;
}
double CalcAccel(double vel)
{
return 3-.000062 * pow(vel,2);
}
Comments
Post a Comment