/* 
 * Problem 23, Page 73-74
 * 
 * This program calculates an NFL quarterback's rating based on the input
 * given: attempted passes, completed passes, interceptions thrown, touchdowns
 * thrown, and total yards gained by passing.
 *
 * Jordan Evatt
 * 9/17/02
 * BE1120-102
 * 
 */

#include <stdio.h>

main() {
   /* initialize the variables used */

   int  att, cmp, yds, td, ints;
   double rating, cmp_p, avgyds, td_p, ints_p;
   
   printf("This program will calculate a quarterback's rating for you. First I need some information about the player.\n");
   
   /* start getting input from the user */
   
   printf("What is the total number of attempted passes? ");
   scanf("%d", &att);
   printf("What is the total number of completed passes? ");
   scanf("%d", &cmp);
   printf("What is the total yards gained passing? ");
   scanf("%d", &yds);
   printf("What is the total number of tpuchdowns thrown? ");
   scanf("%d", &td);
   printf("What is the total number of interceptions thrown? ");
   scanf("%d", &ints);

   /* start making calculations */
   
   cmp_p = (((double) cmp / att) * 100);
   avgyds = ((double) yds / att);
   td_p = (((double) td / att) * 100);
   ints_p = (((double) ints / att) * 100);

   rating = (100.0 / 6) * ( ((cmp_p - 30) / 20.0) + ((avgyds - 3) / 4.0) + (td_p / 5.0) + ((9.5 - ints_p) / 4.0) );
   
   printf("\nAtt\tCmp\tYds\tTd\tInt\tRating\n");
   printf("%d\t%d\t%d\t%d\t%d\t%.1f\n", att, cmp, yds, td, ints, rating);
}

