The player has a maximum of two tries for each question. If the player first answer's is correct, the next problem is presented, otherwise she/he is given a second try. Each correct answer is worth 1 mark. At the end of the quiz, the program displays for each player, The number of correct answers, The number of tries, and The score. The score is calculated by dividing the number of correct answers by number of tries. The program then prints a report of the results to an output file. The report has a tabular format, where each row is the record of each player (Figure 2). The table consists of the following four columns: Player's number, Number of correct answers, Number of tries, and Score The output file name consists of your name and your ID, e.g. Ahmed_14532.txt. Tournament Quiz no corr_ans playr_num no_tries score 4 7 0.57 0.67 Figure 2: Sample output file Tasks: Your program should consist of the following functions: Main: A function that performs file processing, reads number of participants, calls other functions, and generates the output file. showMenu : A function with no parameters and returns a char that represents the level of difficulty. findoperands: A function with one input parameter: the difficulty level. It returns a tuple of two randomly generated operands. userQuiz: A function to process a single player. This function has the difficulty as a unique parameter. It returns a tuple of the following format: numb_of_corr_answers, numb_of_tries , score
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
Step by step
Solved in 4 steps with 6 images