Question

In: Computer Science

Write a C program that calculates the percent saves for a hockey goalie for 4 games...

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.

Solutions

Expert Solution

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


Related Solutions

Welcome to the Bruins Goalie Saves Analysis This program will calculate the percentage of saves for...
Welcome to the Bruins 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...
Your task is to write a program in C or C++ that calculates the total amount...
Your task is to write a program in C or C++ that calculates the total amount of money a person has made over the last year. Your program will prompt the user for dollar amounts showing how much the user has made per job. Some users will have had more than one job, make sure your program allows for this. The program will print out the total made (all jobs) and will print out the federal and state taxes based...
Write a C++ program that calculates mileage reimbursement for a salesperson at a rate of $...
Write a C++ program that calculates mileage reimbursement for a salesperson at a rate of $ 0.35 per mile. Your program should interact with the user in this manner: MILEAGE REIMBURSEMENT CALCULATOR Enter beginning odometer reading: 13505.2 Enter ending odometer reading     : 13810.6 You traveled 305.40 miles. At $ 0.35 per mile, your reimbursement is $ 106.89. The values in red color are inputs for the program. The values in blue color are results of expressions.
Write a program in C++ that calculates the sum of two fractions. The program should ask...
Write a program in C++ that calculates the sum of two fractions. The program should ask for the numerators and denominators of two fractions and then output the sum of the two fractions. You will need to write four functions for this program, one to read the inputted data, one to calculate the sum of the two fractions, one to find the Greatest Common Divider (GCD) between the numerator and denominator and a function that will display the end result....
Write a C program that calculates a student grade in the C Programming Class. Ask the...
Write a C program that calculates a student grade in the C Programming Class. Ask the user to enter the grades for each one of the assignments completed in class: Quiz #1 - 25 points Quiz #2 - 50 points Quiz #3 - 30 points Project #1 - 100 points Project #2 - 100 points Final Test - 100 points The total of the quizzes count for a 30% of the total grade, the total of the projects counts for...
C# CODE C# 1) Write a program that calculates a student's GPA. Remember, an A is...
C# CODE C# 1) Write a program that calculates a student's GPA. Remember, an A is worth 4 points, a B is worth 3 points, a C is worth 2 points, a D is worth 1 point, and an F is worth 0 points. For the purposes of this assignment, assume that all classes carry the same number of credit hours. 2) Use a sentinel-controlled loop to gather a variable number of letter grades. This should terminate the loop if...
Hotel Occupancy C++ Only Program Description Write a program that calculates the occupancy rate for a...
Hotel Occupancy C++ Only Program Description Write a program that calculates the occupancy rate for a hotel. The program should read its data from a file named "hotel.dat". The first line of this file will be a single integer specifying the number of floors in the hotel. Each of the remaining (N) lines will have two integers; the number of rooms on that floor and the number of occupied rooms on that floor. Your program should display the following: How...
In C++, Write a program that calculates pay for either an hourly paid worker or a...
In C++, Write a program that calculates pay for either an hourly paid worker or a salaried worker. Hourly paid workers are paid their hourly pay rate times the number of hours worked. Salaried workers are paid their regular salary plus any bonus they may have earned. The program should declare two structures for the following data: Hourly Paid: HoursWorked HourlyRate Salaried: Salary Bonus The program should also declare a union with two members. Each member should be a structure...
Write a C++ program named, myGrade.cpp, that calculates a letter grade for a student of this...
Write a C++ program named, myGrade.cpp, that calculates a letter grade for a student of this course (CSC100 online) based on three user inputs. This program should begin by printing the title of the application (program) and a brief description of what it does. (Note: this is NOT the same as the program prolog: a prolog is much more detailed, has required elements, and is intended for other programmers reading the cpp file. The title and description displayed by the...
Programming Assignment 1 Performance Assessment Objective: To write a C program (not C++) that calculates the...
Programming Assignment 1 Performance Assessment Objective: To write a C program (not C++) that calculates the average CPI, total processing time (T), and MIPS of a sequence of instructions, given the number of instruction classes, the CPI and total count of each instruction type, and the clock rate (frequency) of the machine. The following is what the program would look like if it were run interactively. Your program will read values without using prompts. Inputs: • Clock rate of machine...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT