/* This is the tenth lab of Lab EE107
The purpose of this lab for counting the pieces of data gathered
is a table showing the distribution of the ratings.
Creating the code and free of syntax and grammatical errors.
Author: Ekwegbalum Unachukwu
Star ID:do2170dt
Date: April 2nd, 2024.
*/
#include <stdio.h>
#define NUM_RESPONSES_EU 15
#define NUM_GRADES_EU 6 // A, B, C, D, E, F
int main() {
char ratings_EU[NUM_RESPONSES_EU];
int count_EU[NUM_GRADES_EU] = {0}; // Initialize counts to zero
// Input ratings
printf("\nEnter the ratings for the television show (A-F):\n");
for (int i = 0; i < NUM_RESPONSES_EU; i++) {
printf("\nRating %d: ", i + 1);
scanf(" %c", &ratings_EU[i]); // Space before %c to consume any leading whitespace
}
// Count ratings
for (int i = 0; i < NUM_RESPONSES_EU; i++) {
switch (ratings_EU[i]) {
case 'A':
count_EU[0]++;
break;
case 'B':
count_EU[1]++;
break;
case 'C':
count_EU[2]++;
break;
case 'D':
count_EU[3]++;
break;
case 'E':
count_EU[4]++;
break;
case 'F':
count_EU[5]++;
break;
default:
printf(" %c", ratings_EU[i]);
}
}
// Display distribution table
printf("\n\n Distribution of Ratings:\n");
printf("A: %d\n", count_EU[0]);
printf("B: %d\n", count_EU[1]);
printf("C: %d\n", count_EU[2]);
printf("D: %d\n", count_EU[3]);
printf("E: %d\n", count_EU[4]);
printf("F: %d\n", count_EU[5]);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: