HW 9/12/2018 1. Generate a table of conversions from feet per second to miles per hour. Start the ft/s column at 0 and increment by 5 ft/s. The last line should contain the value 100 ft/s. (Recall that 1 mi = 5280 ft) 
 



#include <stdio.h>
#include<math.h>
#define PI 3.141593
int main(void) {
     double ft_s=0;
      double mi_h; 
        printf("ft/s       to    mi/h \n");
         while (ft_s <= 100
         {   mi_h = ft_s*0.681
          printf("%8.2f       %6.4f \n",ft_s,mi_h); 
           ft_s += 5;  }
            return 0;
} 2.

#include <stdio.h>
#include <math.h>
#define PI 3.141593
int main(void)
{
int step;
double A1, A2, OMG1, OMG2, height1, height2, l1, l2;
double T1, T2, w1, w2, sum, new_P, new_height, time_incr, t; double maxwave=0
printf("Enter wave period (s) wave height (ft) \n");
scanf("%lf %lf",&T1,&height1);
printf("Enter wave period (s) wave height (ft) \n");
scanf("%lf %lf",&T2,&height2);
l1 = 5.13*T1*T1;
l2 = 5.13*T2*T2;
printf("Wavelengths  (ft)  %.2f %.2f \n",l1,l2);
new_P = T1*T2;
time_incr = new_P/200;
A1 = height1/2; A2 = height2/2;
OMG1 = 1/T1;
OMG2 = 1/T2;
for (step=0; step<=199; step++)
{ t = step*time_incr;
w1 = A1*sin(2*PI*OMG1*t);
  w2 = A2*sin(2*PI*OMG2*t);
sum = w1 + w2;
if (sum > maxwave) maxwave = sum; }
new_height = maxwave*2;
printf("Maximum wave %3.2f ft \n",new_height);
return 0;
} I

#include <stdio.h>
#include <math.h>
#define PI 3.141593
int main(void)
{
int step;
double A1, A2, OMG1, OMG2, height1, height2, l1, l2,maxcrest,mintro;
double T1, T2, w1, w2, sum, new_P, new_height, time_incr, t; double maxwave=0
printf("Enter wave period (s) wave height (ft) \n");
scanf("%lf %lf",&T1,&height1);
printf("Enter wave period (s) wave height (ft) \n");
scanf("%lf %lf",&T2,&height2);
l1 = 5.13*T1*T1;
l2 = 5.13*T2*T2;
printf("Wavelengths  (ft)  %.2f %.2f \n",l1,l2);
new_P = T1*T2;
time_incr = new_P/200;
A1 = height1/2; A2 = height2/2;
OMG1 = 1/T1;
OMG2 = 1/T2;
for (step=0; step<=199; step++)
{ t = step*time_incr;
w1 = A1*sin(2*PI*OMG1*t);
  w2 = A2*sin(2*PI*OMG2*t);
sum = w1 + w2;
if (sum > maxwave) maxwave = sum; }
new_height = maxwave*2; maxcrest= new_height/2; mintro=maxcrest*-1;
printf("Maximum wave %3.2f ft \n",new_height);
printf("max crest and  min trough for combined waves %3.2f %3.2f \n",maxcrest,mintro);


return 0;
}
II

#include <stdio.h>
#include <math.h>
#define PI 3.141593
int main(void)
{
double A1, A2, OMG1, OMG2, height1, height2, l1, l2;
double T1, T2, w1, w2, sum, new_height, t;
printf("Enter wave period (s) wave height (ft) \n");
scanf("%lf %lf",&T1,&height1);
printf("Enter wave period (s) wave height (ft) \n");
scanf("%lf %lf",&T2,&height2);
printf(" Enter time (s)  \n");
scanf("%lf",&t);
l1 = 5.13*T1*T1;
l2 = 5.13*T2*T2;
printf("Wavelengths  (ft)  %.2f %.2f \n",l1,l2);
A1 = height1/2; A2 = height2/2;
OMG1 = 1/T1;
OMG2 = 1/T2;
w1 = A1*sin(2*PI*OMG1*t);
  w2 = A2*sin(2*PI*OMG2*t);
sum = w1 + w2;
new_height = sum*2;
printf("wave height %3.2f ft \n",new_height);
return 0;
}

4



#include <stdio.h>
#include <math.h>
#define PI 3.141593
int main(void)
{
int step;
double A1, A2, OMG1, OMG2, height1, height2, l1, l2;
double theta, T1, T2, w1, w2, sum, new_P, new_height, time_incr, t; double maxwave=0;
printf("Enter wave period (s) wave height (ft) \n");
scanf("%lf %lf",&T1,&height1);
printf("Enter wave period (s) wave height (ft) \n");
scanf("%lf %lf",&T2,&height2);
printf("enter theta \n");
scanf("%lf",&theta);
l1 = 5.13*T1*T1;
l2 = 5.13*T2*T2;
printf("Wavelengths (ft) %.2f %.2f \n",l1,l2);
new_P = T1*T2;
time_incr = new_P/200;
A1 = height1/2; A2 = height2/2;
OMG1 = 1/T1;
OMG2 = 1/T2;
for (step=0; step<=199; step++)
{ t = step*time_incr;
w1 = A1*sin(2*PI*OMG1*t);
w2 = A2*sin((2*PI*OMG2*t)+theta);
sum = w1 + w2;
if (sum > maxwave) maxwave = sum; }
new_height = maxwave*2;
printf("Maximum wave %3.2f ft \n",new_height);
return 0;
}


5

#include <stdio.h>
#include <math.h>
#define PI 3.141593
int main(void)
{
int step;
double A1, A2, OMG1, OMG2, height1, height2, l1, l2;
double theta, T1, T2, w1, w2, sum, new_P, new_height, time_incr, t; double maxwave=0;
printf("Enter wave period (s) wave height (m) \n");
scanf("%lf %lf",&T1,&height1);
printf("Enter wave period (s) wave height (m) \n");
scanf("%lf %lf",&T2,&height2);
printf("enter theta (radian) \n");
scanf("%lf",&theta);
l1 = 5.13*T1*T1;
l2 = 5.13*T2*T2;
printf("Wavelengths (m) %.2f %.2f \n",l1,l2);
new_P = T1*T2;
time_incr = new_P/200;
A1 = height1/2; A2 = height2/2;
OMG1 = 1/T1;
OMG2 = 1/T2;
for (step=0; step<=199; step++)
{ t = step*time_incr;
w1 = A1*sin(2*PI*OMG1*t);
w2 = A2*sin((2*PI*OMG2*t)+theta);
sum = w1 + w2;
if (sum > maxwave) maxwave = sum; }
new_height = maxwave*2;
printf("Maximum wave %3.2f m \n",new_height);
return 0;
}


3
#include <stdio.h>
#include <math.h>
#define PI 3.141593
int main(void)
{
int step;
double A1, A2, OMG1, OMG2, height1, height2, l1, l2,k;
double T1, T2, w1, w2, sum, new_P, new_height, time_incr, t; double maxwave=0;
printf("Enter wave period (s) wave height (ft) \n");
scanf("%lf %lf",&T1,&height1);
printf("Enter wave period (s) wave height (ft) \n");
scanf("%lf %lf",&T2,&height2);
printf("Enter step \n");
scanf("%lf",&k);
l1 = 5.13*T1*T1;
l2 = 5.13*T2*T2;
printf("Wavelengths (ft) %.2f %.2f \n",l1,l2);
new_P = T1*T2;
time_incr = new_P/200;
A1 = height1/2; A2 = height2/2;
OMG1 = 1/T1;
OMG2 = 1/T2;
for (step=0; step<=k; step++)
{ t = step*time_incr;
w1 = A1*sin(2*PI*OMG1*t);
w2 = A2*sin(2*PI*OMG2*t);
sum = w1 + w2;
if (sum > maxwave) maxwave = sum; }
new_height = maxwave*2;
printf("Maximum wave %3.2f ft \n",new_height);
return 0;
}



Comments

Popular posts from this blog