CSCI 240 Program 1 Arithmetic solution

$25.00

Category:

Description

5/5 - (4 votes)

Write a program to calculate the shooting percentage for a team in the National Hockey League. This program will be used as a starting point for the next few assignments so it is important that it is completed and completed correctly.

Basic Program Logic

The first thing to do in the program is to create any variables that are needed to hold/save information for the program. To determine how many variables are needed, think about what information that will be entered by someone using the program and whether it is important for that information to be saved. Think about any calculations that will be performed by the program and whether the results of the calculations need to be saved. To determine the data type for the variables, think about what type of values that someone using the program will be entering or what kind of results will be produced by any calculations. (Note: to ease into writing this first program, the data type for the variables has been specified below.)

Prompt the user for the number of goals that were scored in a game. This is a float or double value that should be stored in a float/double variable.

Prompt the user for the number of shots that were attempted in a game. This is a float or double value that should be stored in a float/double variable.

Calculate the shooting percentage, which is a measure of the rate at which a teams shot attempts result in a goal being scored. The formula to calculate shooting percentage is:

Shooting Percentage = number of goals that were scored / number of shots that were attempted * 100

Finally, display the shooting percentage with an appropriate label (see the sample output that is below)

Program Requirements

    1. At the top of your C++ source code, include a documentation box that resembles the following, making sure to put your name after the “Programmer” label, the section of CSCI 240 that you’re in after the “Section” label, and the due date for the program after the “Date Due” label. A box similar to this one will be put in EVERY source code file that is handed in this semester.

Note: DO NOT put this box within cout statements. It should NOT be displayed as part of the output from the program.

/***************************************************************
CSCI 240         Program 1     Fall 2020

Programmer:

Section:

Date Due:

Purpose: This program calculates and displays the shooting
         percentage for an NHL team
***************************************************************/
    1. Include the following lines of code BELOW the documentation box:
#include <iostream>
#include <iomanip>

using namespace std;
  1. Use type float or double for all of the variables. Make sure to use meaningful variable names.
  2. Make sure and test the program with values other than the ones supplied in the sample output.
  3. Hand in a copy of the source code (the .cpp file) on Blackboard.

Sample Output:

A single run of the program should resemble the following:

Enter the number of goals that were scored: 5
Enter the number of shots that were attempted: 34

The Shooting Percentage is 14.7059

Or

Enter the number of goals that were scored: 1
Enter the number of shots that were attempted: 53

The Shooting Percentage is 1.88679