fork download
  1. /*
  2. Program file: currency.c
  3.  Author: Adam Vale
  4.  Email: Adam_Vale@uml.student.edu
  5.  Date: June 15th 2014
  6.  Assignment: Program #2
  7.  Course #: 90.211.031
  8.  Objective: Write a C program that determines the miles per gallon
  9.  for 3 tanks of gasoline that a user fills in his/her car.
  10. We will explain to the user very clearly what the program will be doing and how they should enter data.
  11.   */
  12.  
  13.  
  14.  
  15. #include <stdio.h>
  16.  
  17. int main()
  18.  
  19. {
  20.  
  21. /* Variable declarations*/
  22.  
  23.  
  24. int count = 1, numbers;
  25. int total = 0;
  26. float average;
  27.  
  28.  
  29.  
  30. while (count <= 6) {
  31.  
  32. /*Introduction of the program to the user as well as programs function*/
  33.  
  34. printf ("Welcome to the Sears mileage calculator.\n");
  35.  
  36. printf ("This program will calculate the miles per gallon for you for three tanks of gas after you have entered the gallons used and miles driven\n");
  37.  
  38. /* Prompt user for numbers of gallons and miles*/
  39.  
  40. printf ("Enter the number of gallons used for tank one #%I\n", count);
  41.  
  42. printf ("Ent the number of miles driven #%I\n",count);
  43.  
  44. printf ("Enter the number of gallons used for tank two #%I\n", count);
  45.  
  46. printf ("Enter the number of miles driven #%I\n", count);
  47.  
  48. printf ("Enter the number of galloons used for tank three #%I\n", count);
  49.  
  50. printf ("Enter the number of miles driven #%I\n", count);
  51.  
  52.  
  53. scanf ("%i", &numbers);
  54.  
  55. total = total + numbers;
  56.  
  57. count++;
  58.  
  59. }
  60. average = total / 6;
  61.  
  62. printf ("Your overall average miles per gallon for three tanks is %f\n", average);
  63.  
  64. printf ("Goodbye");
  65.  
  66. return 0;
  67.  
  68. }
  69.  
Success #stdin #stdout 0s 5272KB
stdin
Enter number #1 : 12.8
Enter number #2 : 287.1
Enter number #3 : 10.3
Enter number #4 : 200.2
Enter number #5 : 5.2
Enter number #6 : 120.9
stdout
Welcome to the Sears mileage calculator.
This program will calculate the miles per gallon for you for three 	tanks of gas after you have entered the gallons used and miles driven
Enter the number of gallons used for tank one #%I
Ent the number of miles driven #%I
Enter the number of gallons used for tank two #%I
Enter the number of miles driven #%I
Enter the number of galloons used for tank three #%I
Enter the number of miles driven #%I
Welcome to the Sears mileage calculator.
This program will calculate the miles per gallon for you for three 	tanks of gas after you have entered the gallons used and miles driven
Enter the number of gallons used for tank one #%I
Ent the number of miles driven #%I
Enter the number of gallons used for tank two #%I
Enter the number of miles driven #%I
Enter the number of galloons used for tank three #%I
Enter the number of miles driven #%I
Welcome to the Sears mileage calculator.
This program will calculate the miles per gallon for you for three 	tanks of gas after you have entered the gallons used and miles driven
Enter the number of gallons used for tank one #%I
Ent the number of miles driven #%I
Enter the number of gallons used for tank two #%I
Enter the number of miles driven #%I
Enter the number of galloons used for tank three #%I
Enter the number of miles driven #%I
Welcome to the Sears mileage calculator.
This program will calculate the miles per gallon for you for three 	tanks of gas after you have entered the gallons used and miles driven
Enter the number of gallons used for tank one #%I
Ent the number of miles driven #%I
Enter the number of gallons used for tank two #%I
Enter the number of miles driven #%I
Enter the number of galloons used for tank three #%I
Enter the number of miles driven #%I
Welcome to the Sears mileage calculator.
This program will calculate the miles per gallon for you for three 	tanks of gas after you have entered the gallons used and miles driven
Enter the number of gallons used for tank one #%I
Ent the number of miles driven #%I
Enter the number of gallons used for tank two #%I
Enter the number of miles driven #%I
Enter the number of galloons used for tank three #%I
Enter the number of miles driven #%I
Welcome to the Sears mileage calculator.
This program will calculate the miles per gallon for you for three 	tanks of gas after you have entered the gallons used and miles driven
Enter the number of gallons used for tank one #%I
Ent the number of miles driven #%I
Enter the number of gallons used for tank two #%I
Enter the number of miles driven #%I
Enter the number of galloons used for tank three #%I
Enter the number of miles driven #%I
Your overall average miles per gallon for three tanks is 5366.000000
Goodbye