联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2019-10-29 09:44

CS 1160 C/C++ Programming

C/C++ Programming Homework #4


Talent Show Score Calculator

A talent show competition has five judges, each of whom awards a score between 0 and 5 to

each performer (Fractional scores, such as 3.8, are allowed). A performer’s final score is

determined by dropping the highest and lowest score received, then averaging the three

remaining scores. Write a program that uses this method to calculate a contestant’s score. It

should include the following functions:

 void getContestantName(string &) should ask the user for the contestant’s name

(please use pass-by-reference)

 double getJudgeData(int) should ask the user for a judge’s score, store it in a

reference parameter variable, and validate it. This function should be called by main once

for each of the five judges.

o The judge # is passed to present the proper prompt to the user.

o Input Validation: Do not accept judge scores lower than 0 or higher than 5. If the

input is invalid, ask the user to enter the score again.

 double calcScore(double, double, double, double, double) should calculate

and return the average of the three scores that remain after dropping the highest and

lowest scores the performer received. This function should be called just once by main()

and should be passed the five scores. (You may change the function prototype)

 void displayResult(string, double) should display the contestant’s name and the

calculated final score.

The last two functions, described below, should be called by calcScore, which uses the returned

information to determine which of the scores to drop.

 double findLowest(double, double, double, double, double) should find and

return the lowest of the five scores passed to it. (You may change the function prototype)

 double findHighest(double, double, double, double, double) should find and

return the highest of the five scores passed to it. (You may change the function prototype)

A program running example is shown below:

Enter the contestant's name: Alice Wonderland

Enter judge #1's score: 3

Enter judge #2's score: 4.3

Enter judge #3's score: 3.3

Enter judge #4's score: 5

Enter judge #5's score: 2.5

Contestant Name: Alice Wonderland

After dropping the lowest and highest scores, the average score was 3.5.

CS 1160 C/C++ Programming

Note:

When you write your program, be sure you:

 use meaningful variable names with good style (i.e., useCamelCase)

 use comments (// single-line or /* Multi-line Comment */) at the start of the program, to

label tricky blocks of code, and to explain the contents of variables

 use global constants where appropriate with good style

ALL_CAPS_AND_UNDERSCORES (Put your global constants after your #include

compiler-directives and before your main function definition so they can be found and

changed easily in future versions of your program.)

 format the user interaction nicely. Provide clear instructions to the user.

Submission requirements:

Submit the following files in the e-Learning homework assignment link by the given deadline

(No late program submission will be accepted):

1. source file talentShowScore.cpp (your C++ source code)

2. A screenshot of your program running with the following inputs:

Contestant name: Alice Wonderland

judge score inputs: 3, 3.5, -2, 5, 3.8, 4. (yes, there is one invalid input)


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp