Beruflich Dokumente
Kultur Dokumente
SUBJECTS INFORMATION:
Subject:
Session:
Programme / Section:
Lecturer:
Coursework Type
Individual Assignment
Lab Task
Coursework Title:
Assignment 3
Group Assignment
Seminar / Tutorial Paper
Coursework Percentage:
Project
Others
6%
ASSESSMENT CRITERIA:
Correctness
Coding
Well formatted output
Readability and
Documentation
SUBMISSION:
2 marks
2 marks
1 marks
1 marks
All completed work should be submitted online through Moodle before or on the due date provided.
SUBMIT AS EARLY AS POSSIBLE. ONLY ONE SUBMISSION IS ALLOWED. IF RE-SUBMISSION IS
NECESSARY, YOU ARE REQUIRED TO REMOVE THE EARLIER SUBMISSION AND THIS MUST BE DONE
BEFORE THE DUE DATE. OTHERWISE YOU WILL BE PENALIZED FOR LATE SUBMISSON.
DUE DATE:
COURSEWORK SPECIFICATION
This assignment covers the following topics:
Functions
Remember that:
1. All programs should be able to run on the labs computers.
2. You must put the following information on the header of each text and source file you will be submitting in
this assignment:
Students full name:
Students ID:
Modification Date:
Purpose of this file (or program):
3. Assignments that are not able to be compiled will result in zero mark given to the assignment.
4. You must only use the C++ features that have already been covered in the lectures
TASKS:
Question 1
The cost to become a member of a fitness center is as follows: (a) Senior citizens discount is 30%, (b) If
membership is bought and paid for 12 or more months, the discount is 15%, (c) If more than five personal
training sessions are bought and paid for, the discount on each session is 20%.
Write a menu-driven program that determines the cost of a new membership. Your program must contain a
function that displays the general information about the fitness center and its charges; a function to read all of the
necessary information to determine the membership cost; and a function to determine the membership cost. Use
appropriate parameters to pass information in and out of a function. Do not use global variables.
Question 2
Write a program that calculates the average of a group of test scores, where the lowest score in the group is
dropped (not to be counted). It should use the following functions:
getScore() function to read a test score from the user, validate it, and return it to the main()
function. The program should call this function five times to read five inputs.
calcAverage() function to calculate and return the average of the four highest scores.
findLowest() function to find and return the lowest of the five scores passed to it. This function
should be called by calcAverage() function to determine which score to be dropped.
Question 3
Write a program that lets the user play the game of Rock, Paper, and Scissors, against the computer. The
program should work as follows:
When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1,
then the computer has chosen rock. If the number is 2, then the computer has chosen paper and if the
number is 3, then the computer has chosen scissors. Do not display the computers choice yet. This
should be done in a function called getComputerInput(). The random number is returned to main().
Next, get the user to input his/her choice of rock, paper, or scissors through the keyboard. You can use a
menu if you prefer. This should be done in another function called getPlayerInput() and the users choice
should be returned to main().
Pass both computers choice and players choice to another function called getWinner(). The function
should determine and return the winner to main(). If there is no winner, the function should return a
suitable value to indicate this. A winner is selected according to the following rules:
If one player chooses rock and the other player chooses scissors, then rock wins. (The rock
smashes the scissors)
If one player chooses scissors and the other player chooses paper, then scissors wins. (Scissors cut
the paper)
If one player chooses paper and the other player chooses rock, then the paper wins. (Paper wraps
rock)
If both players make the same choice, there is no winner.
The main() function should display the computers choice and declare the winner. If there is no winner,
the game must be played again to determine the winner.