Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please complete this C++ program under the topic of Control statement/Structure, Functions and Arrays only. I have provided the source code and complete the codes

Please complete this C++ program under the topic of Control statement/Structure, Functions and Arrays only.

I have provided the source code and complete the codes according to the question.

image text in transcribedimage text in transcribed

//Please write the answer in the following source code

#include #include #include #include #include

using namespace std;

//------------------------------------------------------------------------------- // Function : readScores // Purpose : to check if file is succesfully open // : to read data from scores.txt and put in parrall arrays // Parameters: // names : array of strings // scores : array of integers // numScores : array of integers // Task 1: Complete the definition of function "readScores" [12 Marks]

void readScores(int scores[], string names[], int &numScores) {

}

//------------------------------------------------------------------------------- // Function : getHighestScore // Purpose : to find the index of array with the highest score // Parameters: // scores : array of integers // size : size of array // Return value: the index with the highest score // // Task 2: Complete the definition of function "getHighestScore" [6 Marks]

int getHighestScore (int scores[], int size) {

}

//------------------------------------------------------------------------------- // Function : getLowestScore // Purpose : to find the index of array with the lowest score // Parameters: // scores : array of integers // size : size of array // Return value: the index with the lowest score // // Task 3: Complete the definition of function "getLowestScore" [6 Marks]

int getLowestScore (int scores[], int size) {

}

//------------------------------------------------------------------------------- // Function : averageScore // Purpose : to calculate the average score // Parameters: // scores : array of integers // size : size of array // Return value: the average of scores // // Task 4: Complete the definition of function "averageScore" [5 Marks]

float averageScore(int scores[], int size) {

}

//------------------------------------------------------------------------------- // Function : Main // Purpose : to call readScores, getHighestScore, getLowestScore and averageScore function // : to print all the data read from the input file, highest score, lowest score // and average score into report.txt file

int main( ) { int size; //Size of array int scores[100]; //List of scores string names[100]; //List of players' name // **** Task 5: Using appropriate functions defined above, read inputs from the input file, // then find the highest and lowest score. Finally, calculate the average of // the scores (9.5 marks)

// **** Task 6: Print all the data you read, find and calculate from Task 5 into the output file // with correct output formatting (18.5 marks)

// **** Task 7: The program is able to run and display correct output in the output file (3 marks) return 0; }

Problem 60 Marks Johor Darul Ta'zim Football Club, or simply known as JDT is the most popular football team in Malaysia. JDT is the first team in the country to win four consecutive league titles (2014, 2015, 2016, and 2017). Before this achievement, no team had ever won the league championship more than twice in a row since the league system was first introduced in Malaysia in 1979. Assumed that you are a UTM practical student currently attached to this club. You have been asked to write a program for your supervisor to facilitate the JDT Manager to keep track the performance scores of each player. There are seven tasks already listed to complete the program Edit the source code SBT2_051217.cpp according to the tasks given by the supervisor. The tasks given as follows; TASK 1: Write a function named readScores that takes two array parameters, an array of strings and an array of integers. The function should scan through the input file named scores.txt. Make sure you only continue reading the file if the file is successfully opened, otherwise print the error message and exit the program. Set the string array entry at index 0 to the name of player along with the scores of the respective player. [12 Marks] TASK 2: Complete the definition of function getHighestScore. This function should compare the scores among the players and then find the highest score. Once identified, this function returns the index of array with the highest score. [6 Marks) TASK 3: Complete the definition of function getLowestScore. This function works similar with TASK 2 but it's for finding the lowest score. [6 Marks] TASK 4: Complete the definition of function averageScore. This function calculates the average of the scores and return this value back into calling function. [5 Marks] TASK 5: Using appropriate functions defined above, read inputs from the input file, then find the highest and lowest score. Finally, calculate the average of the scores. [9.5 marks] TASK 6: Continue to print all the results from Task 5 into the file named report.txt. Note: Use proper output formatting. Your full report should look like this: PLAYER'S NAME SCORES Farizal Hasbullah Afig Marcos Safiq Hazwan Gabriel Kunanlan Darren Safawi 7852 6643 6561 7332 8991 7013 7116 6986 6559 6890 HIGHEST SCORE : 8991 (Safiq) LOWEST SCORE : 6559 (Darren) AVERAGE SCORE: 7194.30 [18.5 Marks] TASK 7: The program is able to run and display correct output in the output file. [3 Marks] The assessment criteria is shown in Table 1

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

Online Market Research Cost Effective Searching Of The Internet And Online Databases

Authors: John F. Lescher

1st Edition

0201489295, 978-0201489293

More Books

Students also viewed these Databases questions