Computer Science Homework Help

Cypress College String Parameter Codes Project

 

Write a C++ program that calculates how many points a team scored in a basketball game. It should ask the user how many free throws, two-point, and three-point shots the team made. To help you, your program should include the following functions:

    • getNum: Has a string parameter. This function will get an integer from the user. Your function should first print the string that is passed to it (this allows the client to pass a different ‘prompt’ for the user each time the function is called). Afterward, retrieve an int from the user. If the user enters a negative number, keep asking for a new number until a number 0 or above is entered, then return it.
    • getTotalScore: Has three int parameters, one for free throws, one for two-point shots, and one for three-point shots. Calculate and return the team’s total score (free throws are worth one point).

Your main function should call getNum three times, passing a different string each time (i.e. “How many free throws did your team make?” the first time). Assign the return values of each call to three separate variables. Then, pass them to get total score, and print the result.