Homework Number 2

HOMEWORK PART 1: ARCHEOLOGY


/* This code will take user preferences on input and output values. Then it will prompt the user for the length of a femur and humerus in the preferred input form. It will then calculate estimates of the human height based on the femur and humerus. It will then return those values in the desired output form. */
#include <stdio.h>
#include <math.h>
int main(void) {
char input_method, output_method;
float femur_length, humerus_length, femur_length_f_only, femur_length_i_only, humerus_length_f_only, humerus_length_i_only, femur_inches, humerus_inches, femur_female_height_i, femur_female_height_f, femur_female_height_f_only, femur_female_height_i_only, femur_female_height_c, femur_male_height_i, femur_male_height_f, femur_male_height_f_only, femur_male_height_i_only, femur_male_height_c, humerus_female_height_i,humerus_female_height_f, humerus_female_height_f_only, humerus_female_height_i_only, humerus_female_height_c, humerus_male_height_i, humerus_male_height_f, humerus_male_height_f_only, humerus_male_height_i_only, humerus_male_height_c;

printf("Please select input method: (f)eet, (i)nches, feet (a)nd inches, (c)entimeters \n");
scanf(" %c", &input_method);
if (input_method == 'a') {
  printf("Enter Femur Length (__(feet) __(inches)):");
  scanf(" %i %i", &femur_length_f_only, &femur_length_i_only);
  printf("Enter Humerus Length (__(feet) __(inches)):");
  scanf(" %i %i", &humerus_length_f_only, &humerus_length_i_only );
  }
else {
  printf("Enter Femur Length:");
  scanf(" %f", &femur_length);
  printf("Enter Humerus Length:");
  scanf(" %f", &humerus_length);
}
 printf("Please select output method: (f)eet, (i)nches, feet (a)nd inches, (c)entimeters \n");
scanf(" %c", &output_method);


if (input_method == 'f'){
  femur_inches = femur_length*12;
  femur_female_height_i = femur_inches*1.94 + 28.7;
  femur_female_height_f = (femur_female_height_i)/12;
  femur_female_height_f_only = (int)(femur_female_height_f);
  femur_female_height_i_only = (femur_female_height_f - femur_female_height_f_only)*12;
  femur_female_height_c = 2.54*femur_female_height_i;
 
  femur_male_height_i = femur_inches*1.88 + 32;
  femur_male_height_f = (femur_female_height_i)/12;
  femur_male_height_f_only = (int)(femur_female_height_f);
  femur_male_height_i_only = (femur_female_height_f - femur_female_height_f_only)*12;
  femur_male_height_c = 2.54*femur_female_height_i;

  humerus_inches = humerus_length*12;
  humerus_female_height_i = humerus_inches*2.8 + 28.2;
  humerus_female_height_f = (humerus_female_height_i)/12;
  humerus_female_height_f_only = (int)(humerus_female_height_f);
  humerus_female_height_i_only = (humerus_female_height_f - humerus_female_height_f_only)*12;
  humerus_female_height_c = 2.54*humerus_female_height_i;
 
  humerus_male_height_i = humerus_inches*2.9 + 27.9;
  humerus_male_height_f = (humerus_male_height_i)/12;
  humerus_male_height_f_only = (int)(humerus_male_height_f);
  humerus_male_height_i_only = (humerus_male_height_f - humerus_female_height_f_only)*12;
  humerus_male_height_c = 2.54*humerus_male_height_i;
  }
if (input_method == 'i') {
  femur_inches = femur_length;
  femur_female_height_i = femur_inches*1.94 + 28.7;
  femur_female_height_f = (femur_female_height_i)/12;
  femur_female_height_f_only = (int)(femur_female_height_f);
  femur_female_height_i_only = (femur_female_height_f - femur_female_height_f_only)*12;
  femur_female_height_c = 2.54*femur_female_height_i;
 
  femur_male_height_i = femur_inches*1.88 + 32;
  femur_male_height_f = (femur_female_height_i)/12;
  femur_male_height_f_only = (int)(femur_female_height_f);
  femur_male_height_i_only = (femur_female_height_f - femur_female_height_f_only)*12;
  femur_male_height_c = 2.54*femur_female_height_i;

  humerus_inches = humerus_length;
  humerus_female_height_i = humerus_inches*2.8 + 28.2;
  humerus_female_height_f = (humerus_female_height_i)/12;
  humerus_female_height_f_only = (int)(humerus_female_height_f);
  humerus_female_height_i_only = (humerus_female_height_f - humerus_female_height_f_only)*12;
  humerus_female_height_c = 2.54*humerus_female_height_i;
 
  humerus_male_height_i = humerus_inches*2.9 + 27.9;
  humerus_male_height_f = (humerus_male_height_i)/12;
  humerus_male_height_f_only = (int)(humerus_male_height_f);
  humerus_male_height_i_only = (humerus_male_height_f - humerus_female_height_f_only)*12;
  humerus_male_height_c = 2.54*humerus_male_height_i;
  }
if (input_method == 'a') {
  femur_inches = (femur_length_f_only*12)+ (femur_length_i_only);
  femur_female_height_i = femur_inches*1.94 + 28.7;
  femur_female_height_f = (femur_female_height_i)/12;
  femur_female_height_f_only = (int)(femur_female_height_f);
  femur_female_height_i_only = (femur_female_height_f - femur_female_height_f_only)*12;
  femur_female_height_c = 2.54*femur_female_height_i;
 
  femur_male_height_i = femur_inches*1.88 + 32;
  femur_male_height_f = (femur_female_height_i)/12;
  femur_male_height_f_only = (int)(femur_female_height_f);
  femur_male_height_i_only = (femur_female_height_f - femur_female_height_f_only)*12;
  femur_male_height_c = 2.54*femur_female_height_i;

  humerus_inches = (humerus_length_f_only*12) + (humerus_length_i_only);
  humerus_female_height_i = humerus_inches*2.8 + 28.2;
  humerus_female_height_f = (humerus_female_height_i)/12;
  humerus_female_height_f_only = (int)(humerus_female_height_f);
  humerus_female_height_i_only = (humerus_female_height_f - humerus_female_height_f_only)*12;
  humerus_female_height_c = 2.54*humerus_female_height_i;
 
  humerus_male_height_i = humerus_inches*2.9 + 27.9;
  humerus_male_height_f = (humerus_male_height_i)/12;
  humerus_male_height_f_only = (int)(humerus_male_height_f);
  humerus_male_height_i_only = (humerus_male_height_f - humerus_female_height_f_only)*12;
  humerus_male_height_c = 2.54*humerus_male_height_i;
  }
 if(input_method == 'c') {
  femur_inches = femur_length*0.393701;
  femur_female_height_i = femur_inches*1.94 + 28.7;
  femur_female_height_f = (femur_female_height_i)/12;
  femur_female_height_f_only = (int)(femur_female_height_f);
  femur_female_height_i_only = (femur_female_height_f - femur_female_height_f_only)*12;
  femur_female_height_c = 2.54*femur_female_height_i;
 
  femur_male_height_i = femur_inches*1.88 + 32;
  femur_male_height_f = (femur_female_height_i)/12;
  femur_male_height_f_only = (int)(femur_female_height_f);
  femur_male_height_i_only = (femur_female_height_f - femur_female_height_f_only)*12;
  femur_male_height_c = 2.54*femur_female_height_i;

  humerus_inches = humerus_length*0.393701;
  humerus_female_height_i = humerus_inches*2.8 + 28.2;
  humerus_female_height_f = (humerus_female_height_i)/12;
  humerus_female_height_f_only = (int)(humerus_female_height_f);
  humerus_female_height_i_only = (humerus_female_height_f - humerus_female_height_f_only)*12;
  humerus_female_height_c = 2.54*humerus_female_height_i;
 
  humerus_male_height_i = humerus_inches*2.9 + 27.9;
  humerus_male_height_f = (humerus_male_height_i)/12;
  humerus_male_height_f_only = (int)(humerus_male_height_f);
  humerus_male_height_i_only = (humerus_male_height_f - humerus_female_height_f_only)*12;
  humerus_male_height_c = 2.54*humerus_male_height_i;
 }
 if (output_method == 'f') {
  printf("Femur Female Estimate: %3.3f feet \n", femur_female_height_f);
  printf("Femur Male Estimate: %3.3f feet \n", femur_male_height_f);
  printf("Humerus Female Estimate: %3.3f feet \n", humerus_female_height_f);
  printf("Humerus Male Estimate: %3.3f feet \n", humerus_male_height_f); }

if (output_method == 'i') {
  printf("Femur Female Estimate: %3.3f inches \n", femur_female_height_i);
  printf("Femur Male Estimate: %3.3f inches \n", femur_male_height_i);
  printf("Humerus Female Estimate: %3.3f inches \n", humerus_female_height_i);
  printf("Humerus Male Estimate: %3.3f inches \n",humerus_male_height_i); }
 if (output_method == 'a') {
  printf("Femur Female Estimate: %3.3f feet and %2.3f inches \n", femur_female_height_f_only, femur_female_height_i_only);
  printf("Femur Male Estimate: %3.3f feet and %2.3f inches \n", femur_male_height_f_only, femur_male_height_i_only);
  printf("Humerus Female Estimate: %3.3f feet and %2.3f inches \n", humerus_female_height_f_only, humerus_female_height_i_only);
  printf("Humerus Male Estimate: %3.3f feet abd %2.3f inches \n", humerus_male_height_f_only, humerus_male_height_f_only); }
 if (output_method == 'c') {
  printf("Femur Female Estimate: %3.3f centimeters \n", femur_female_height_c);
  printf("Femur Male Estimate: %3.3f centimeters \n", femur_male_height_c);
  printf("Humerus Female Estimate: %3.3f centimeters \n", humerus_female_height_c);
  printf("Humerus Male Estimate: %3.3f centimeters \n", humerus_male_height_c);}

return 0;
}



HOMEWORK PART 2: AMINO ACIDS

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

int main(void) {
int o, c, n, s, h;
double weight, average_weight;
char more = 'y', acid, path;
printf("Would you like to know the weight of a (k)nown amino acid or make up your (o)wn molecule?");
scanf("%c", &path);
/*This path (known) allows the user to pick an amino acid from a list of amino acids, then calculates and prints the weight of the given amino acid. It also calculates the average weight of each atom in the molecule. Then it prompts the user to see if they would like to know the weight of another, and repeats until user is done. */
if (path == 'k')
while (more == 'y'){
 printf("Pick an amino acid: (a)lanine, a(r)ginine, aspara(g)ine, as(p)artic, c(y)steine, g(l)utamic, gl(u)tamine, glyc(i)ne, (h)istidine, is(o)leucine, leu(c)ine, lysin(e), (m)etheionine, phenylalanine (b), proline (d), serine (f), (t)hreonine, tryptophan (j), tyrosine (k), (v)aline \n");
 scanf(" %c", &acid);
 if (acid == 'a')
   o = 2,c = 3, n = 1, s = 0, h =7;
 if (acid == 'r')
   o = 2, c = 6, n = 4, s = 0, h = 15;
 if (acid == 'g')
   o = 3, c = 4, n = 2, s = 0, h = 8;
 if (acid == 'p')
   o = 4, c = 4, n = 1, s = 0, h = 6;
 if (acid == 'y')
   o = 2,c = 3, n = 1, s = 1, h =7;
 if (acid == 'l')
   o = 4, c = 5, n = 1, s = 0, h = 8;
 if (acid == 'u')
   o = 3, c = 5, n = 2, s = 0, h = 10;
 if (acid == 'i')
   o = 2, c = 2, n = 1, s = 0, h = 5;
 if (acid == 'h')
   o = 2,c = 6, n = 3, s = 0, h =10;
 if (acid == 'o')
   o = 2, c = 6, n = 1, s = 0, h = 13;
 if (acid == 'c')
   o = 2, c = 6, n = 1, s = 0, h = 13;
 if (acid == 'e')
   o = 2, c = 6, n = 2, s = 0, h = 15;
 if (acid == 'm')
   o = 2,c = 5, n = 1, s = 1, h =11;
 if (acid == 'b')
   o = 2, c = 9, n = 1, s = 0, h = 11;
 if (acid == 'd')
   o = 2, c = 5, n = 1, s = 0, h = 10;
 if (acid == 'f')
   o = 3, c = 3, n = 1, s = 0, h = 7;
 if (acid == 't')
   o = 3,c = 4, n = 1, s = 0, h =9;
 if (acid == 'j')
   o = 2, c = 11, n = 2, s = 0, h = 11;
 if (acid == 'k')
   o = 3, c = 9, n = 1, s = 0, h = 11;
 if (acid == 'v')
   o = 2, c = 5, n = 1, s = 0, h = 11;
 
 weight =  (15.992*o) + (12.011*c) + (14.00674*n) + (32.066*s) +  (1.00794*h);
 printf("The weight of given molecule is %3.3f amu \n", weight);
 average_weight = weight/(o+c+n+s+h);
 printf("The average weight of each atom in given molecule is %3.3f amu \n", average_weight);


 printf("Would you like to know the weight of an amino acid? (y/n)");
 scanf(" %c", &more); }
/*This path (own) will compute the weight of a molecule given the number of each element’s atoms. It will then compute the average weight of each atom in the molecule */

if (path == 'o')
while (more == 'y'){
 printf("How many Oxygens?");
 scanf("%i", &o);
 printf("How many Carbons?");
 scanf("%i", &c);
 printf("How many Nitrogens?");
 scanf("%i", &n);
 printf("How many Sulfurs?");
 scanf("%i", &s);
 printf("How many Hydrogens?");
 scanf("%i", &h);
 weight =  (15.992*o) + (12.011*c) + (14.00674*n) + (32.066*s) +  (1.00794*h);
 printf("The weight of given molecule is %3.3f amu \n", weight);
 average_weight = weight/(o+c+n+s+h);
 printf("The average weight of each atom in given molecule is %3.3f amu \n", average_weight);
 printf("Would you like to know the weight of another amino acid? (y/n)");
 scanf(" %c", &more); }


return 0;
}//


HOMEWORK PART 3: ARDUINO




















Comments

Popular posts from this blog

Seismic Code

Strings

BMP180 Code + Library to SD card