Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***C++ Code*** What this Assignment Is About: -Learn to define and call void & non-void functions -Learn to use reference variables Coding Guidelines for All

***C++ Code***

What this Assignment Is About:

-Learn to define and call void & non-void functions

-Learn to use reference variables

Coding Guidelines for All Labs/Assignments (You will be graded on this)

-Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc).

-Keep identifiers to a reasonably short length.

-Use upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for all other identifiers (variables, methods, objects).

-Use tabs or spaces to indent code within blocks (code surrounded by braces). This includes classes, methods, and code associated with ifs, switches and loops. Be consistent with the number of spaces or tabs that you use to indent.

-Use white space to make your program more readable.

-Use comments properly before or after the ending brace of classes, methods, and blocks to identify to which block it belongs.

1. Introduction

Dance Competiton has 5 judges, each of whom awards a score between 0 and 10 to a performer. Fractional scores, such as 8.25, are allowed. A performer will be judged in 3 catagories - dancing skill, performance and interpretion of the music. For each catagory, the highest and lowest of the judge's socre will be dropped, then the average of the remaining 3 scores will be the performer's score for that catagory. The sum of a performer's score in dancing skill, performance and music interpretion will be his/her final score in the competition. See below table for one example:

Program Components Judge 1 Judge 2 Judge 3 Judge 4 Judge 5 Lowest Highest Average
Dancing Skills 7.75 8.00 7.25 9.15 7.00 7.00 9.15 7.67
Performance 7.87 8.25 8.97 9.00 7.25 7.25 9.00 8.36
Interpretion of the music 7.98 8.25 8.75 9.25 9.36 7.98 9.36 8.75
Final Score 24.78

2. Functions

In this assignment, you're required to write a program that uses these rules to calculate and display a contestant's score. Your program MUST at least include the following functions, feel free to add any extra functions if necessary.

Function Name Description
main This is the main() function which we will start the program with, pseudo code for the main: Call getJudgeData to get 5 judgs' scores for catagory "Dancing Skill" Call calcScore on above 5 scores to get the average of "Dancing Skill" Call getJudgeData to get 5 judgs' scores for catagory "Performance" Call calcScore on above 5 scores to get the average of "Performance" Call getJudgeData to get 5 judgs' scores for catagory "Music Interpretion" Call calcScore on above 5 scores to get the average of "Music Interpretion" Compute the total score, then ouput.
getJudgeData This function should allow the user to enter 5 judges' scores and store them in five reference variables. This function should also call checkScore function on each of the five scores to make sure they are all within the range 0 to 10. In case any of the five scores are out of range, show the following message on screen and ask the user to re-enter. One or more of the judge scores are invalid. Score must between 0 to 10. Please re-enter scores:
findLowest This function should find and return the lowest of the 5 scores passed to it.
findHighest This function should find and return the highest of the 5 scores passed to it.
checkScore This function takes one score as an input parameter and returns true if it's valid (within the range of [0, 10]), otherwise it should return false.
calcScore This function should take 5 scores as input parameters, calculate and return the average of the 3 scores that remain after dropping the highest and lowest scores the performer received. i.e. this function should call findLowest, findHighest functions.

Note:

-Except for main(), for all above functions, you need to decide its header first, this includes the return data tye and formal parameter list. For formal parameter list, you will need to decide the number, data type of each parameter, etc.

-Don't forget to declare the functions first.

-For function getJudgeData and use of reference variable, check the e-Textbook we posted on Blackboard pp.348 Section 6.13 "Using Reference Variables as Parameters", or study this reference variable sample code.

-All output scores should be formatted with 2 decimal digits.

3. Sample run

User input is in bold.

Sample run #1

Enter five judge scores for Dancing Skills: 7.75 8.00 7.25 9.15 7.00 Drop the highest: 9.15 Drop the lowest: 7.00 Dancing Skills Score: 7.67 Enter five judge scores for Performance: 7.87 8.25 8.97 9.00 7.25 Drop the highest: 9.00 Drop the lowest: 7.25 Performance Score: 8.36 Enter five judge scores for Music: 7.98 8.25 8.75 9.25 9.36 Drop the highest: 9.36 Drop the lowest: 7.98 Music Score: 8.75 Final score = 24.78

Sample run #2

Enter five judge scores for Dancing Skills: 5.6 7.82 7.15 8.17 6.75 Drop the highest: 8.17 Drop the lowest: 5.60 Dancing Skills Score: 7.24 Enter five judge scores for Performance: 6.75 11.2 8.25 9.35 4.25 One or more of the judge scores are invalid. Score must between 0 to 10.

Please re-enter scores: 6.75 9.20 8.25 9.35 4.25 Drop the highest: 9.35 Drop the lowest: 4.25 Performance Score: 8.07 Enter five judge scores for Music: 7.25 -1.20 7.52 7.67 6.98 One or more of the judge scores are invalid. Score must between 0 to 10.

Please re-enter scores: 7.25 7.20 7.52 7.67 6.98 Drop the highest: 7.67 Drop the lowest: 6.98 Music Score: 7.32 Final score = 22.63

4. Misce. Programming Requirements

-Your program must also meet the specifications stated as below:

-See the sample output file at the end of the specification.

-Pick and use identifiers which are self-descriptive. One-letter variable names should not be used. As an example, if you were referring to the ticket price, the variable needed might be declared as double price; instead of double x;

Test Case #1 Input:

5.75 8.25 7.75 8.50 9.10 6.75 7.15 7.87 8.29 9.20 7.20 7.88 8.50 8.95 8.75 

Test Case #1 Output:

Enter five judge scores for Dancing Skills: Drop the highest: 9.10 Drop the lowest: 5.75 Dancing Skills Score: 8.17 Enter five judge scores for Performance: Drop the highest: 9.20 Drop the lowest: 6.75 Performance Score: 7.77 Enter five judge scores for Music: Drop the highest: 8.95 Drop the lowest: 7.20 Music Score: 8.38 Final score = 24.31 

Test Case #2 Input:

5.6 7.82 7.15 8.17 6.75 6.75 11.2 8.25 9.35 4.25 6.75 9.20 8.25 9.35 4.25 7.25 -1.20 7.52 7.67 6.98 7.25 7.20 7.52 7.67 6.98 

Test Case #2 Output:

Enter five judge scores for Dancing Skills: Drop the highest: 8.17 Drop the lowest: 5.60 Dancing Skills Score: 7.24 Enter five judge scores for Performance: One or more of the judge scores are invalid. Score must between 0 to 10. Please re-enter scores: Drop the highest: 9.35 Drop the lowest: 4.25 Performance Score: 8.07 Enter five judge scores for Music: One or more of the judge scores are invalid. Score must between 0 to 10. Please re-enter scores: Drop the highest: 7.67 Drop the lowest: 6.98 Music Score: 7.32 Final score = 22.63 

***C++ Code***

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions