HW_3
Comment: The coding is starting to get more difficult at this point, I went to different forums and watched you tube videos on how to trouble shoot, because I forgot a parenthesis. I didn't understand interpolation initially, and had to watch a you tube video on it. I probably wouldn't have got the code to work if Mr.Mason din't give us a sample code, god bless! The arduino debounce I never got it to work properly, everytime I pushed the button it wouldn't cycle properly. So, I'm assuming that I didn't get the code to work properly, or maybe it's a mechanical problem.
#include <stdio.h>
#include <math.h>
int main(void)
{
/* declare variables */
double a,b,c, f_a,f_b,f_c;
printf("Enter first salinity and freezing temperature: \n");
scanf("%lf %lf",&a,&f_a);
printf("enter second salinity and freezing temperature in farehient: \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);
printf("new freezing termperature in degrees F: %lf \n", f_b);
return 0;
}
#include <stdio.h>
#include <math.h>
int main(void)
{
/* declare variables */
double a,b,c, f_a,f_b,f_c;
printf("Enter first salinity and freezing temperature: \n");
scanf("%lf %lf",&a,&f_a);
printf("enter second salinity and freezing temperature in farehient: \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);
printf("new freezing termperature in degrees F: %lf \n", f_b);
return 0;
}
/* salinity problem 2 */
#include <stdio.h>
#include <math.h>
int main(void)
{
/* declare variables */
double a,b,c, f_a,f_b,f_c,t_c;
printf("Enter first salinity and freezing temperature in Farehient: \n");
scanf("%lf %lf",&a,&f_a);
printf("enter second salinity and freezing temperature in farehient: \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);
t_c = (f_b -32)*.555555;
printf("new freezing termperature in degrees F: %lf \n", t_c);
return 0;
}
#include <stdio.h>
#include <math.h>
int main(void)
{
/* declare variables */
double a,b,c, f_a,f_b,f_c,t_c;
printf("Enter first salinity and freezing temperature in Farehient: \n");
scanf("%lf %lf",&a,&f_a);
printf("enter second salinity and freezing temperature in farehient: \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);
t_c = (f_b -32)*.555555;
printf("new freezing termperature in degrees F: %lf \n", t_c);
return 0;
}
problem 3)
No, if the user inputs the data in Centigrade, then there wouldn't need to be any change. if the user input the values in Fahrenheit then there would have to be a change in code to convert Fahrenheit to Centigrade
problem 4)
/* salinity problem */
#include <stdio.h>
#include <math.h>
int main(void)
{
/* declare variables */
double a,b,c, f_a,f_b,f_c,t_c;
printf("Enter first temperature in fahrenheit and salinity: \n");
scanf("%lf %lf",&a,&f_a);
printf("enter second Temperature and salinity: \n");
scanf("%lf %lf",&c, &f_c);
printf("enter new temperature:\n");
scanf(" %lf", &b);
/* use linear interpolation to compute new freezing temperature. */
f_b = f_a + (b-a)/(c-a)*(f_c - f_a);
printf("new salinity: %lf \n", f_b);
return 0;
}
#include <stdio.h>
#include <math.h>
int main(void)
{
/* declare variables */
double a,b,c, f_a,f_b,f_c,t_c;
printf("Enter first temperature in fahrenheit and salinity: \n");
scanf("%lf %lf",&a,&f_a);
printf("enter second Temperature and salinity: \n");
scanf("%lf %lf",&c, &f_c);
printf("enter new temperature:\n");
scanf(" %lf", &b);
/* use linear interpolation to compute new freezing temperature. */
f_b = f_a + (b-a)/(c-a)*(f_c - f_a);
printf("new salinity: %lf \n", f_b);
return 0;
}
Comments
Post a Comment