In: Computer Science
Write a C program that calculates the percent saves for a hockey
goalie for 4 games and
the overall percentage of saves which is saves divided by the sum
of goals plus saves.
input->process->output->repeat
The program should prompt the user to enter the number of goals and
the number of
saves for each of the 4 games. The program should then calculate
and display the percent
saves obtained for each game. Once processing is complete for the
games, the program
will calculate the overall percent saves (total saves / sum of
total saves and total goals
and display the results. Then print a friendly exit message as
shown below.
Once you create, compile, link and run your program, your program
should present the
following input/output dialog to the user:
Welcome to the Goalie Saves Analysis
This program will calculate the percentage of saves for
a hockey goalie for 4 games after you have entered the
games and saves for the goalie.
Enter the number of goals for game #1: 3
Enter the number of saves for game #1: 22
The percent saves for game #1 is 88.0%
Enter the number of goals for game #2: 4
Enter the number of saves for game #2: 33
The percent saves for game #2 is 89.2%
Enter the number of goals for game #3: 1
Enter the number of saves for game #3: 16
The percent saves for game #3 is 94.1%
Enter the number of goals for game #4: 0
Enter the number of saves for game #4: 22
The percent saves for game #4 is 100.0%
The percent saves for 4 games for this goalie is 92.1%
Thanks for using the Bruins Goalie Saves Analysis
program.
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
_________________
#include <stdio.h>
int main(void) {
//Declaring variables
int saves,goals,totSaves=0,totGoals=0,i;
float percent,overallPercent;
printf("Welcome to the Goalie Saves Analysis\n");
printf("This program will calculate the percentage of saves
for\n");
printf("a hockey goalie for 4 games after you have entered
the\n");
printf("games and saves for the goalie.\n");
for(i=1;i<=4;i++)
{
//Getting the inputs entered by the user
printf("\nEnter the number of goals for game
#%d: ",i);
scanf("%d",&saves);
printf("Enter the number of saves for game #d:
",i);
scanf("%d",&goals);
//Calculating the percentage of saves
percent=100-(((float)(saves)/(saves+goals))*100.0);
printf("The percent saves for game #%d is
%.1f%%",i,percent);
totSaves+=saves;
totGoals+=goals;
}
//calculating the overall saves percentage
overallPercent=100-(((float)(totSaves)/(totSaves+totGoals))*100.0);
printf("\nThe percent saves for 4 games for this goalie is
%.1f%",overallPercent);
printf("\nThanks for using the Bruins Goalie Saves Analysis
program.");
return 0;
}
______________________________
Output:
_______________Could you plz rate me well.Thank You