Starting from:

$29

Assignment 2: Who doesn’t want to be a millionaire?


In this assignment, you have to program a game called ‘Who doesn’t want to be a millionaire?’
by writing definitions for each of the function prototypes based on the descriptions given
below.
Topics covered: All statements from A1, Conditional statements (if / else, if, nested if, multibranch nested if, switch), Loops (while, do-while, for, nested loops), User-defined functions.
DONTs:
DO NOT use global variables. Using global variables will result in automatic zero.
DO NOT use goto statements. Using goto will result in automatic zero.
DOs:
● Submit a single C file containing your program. To submit, upload your C file to the
submission box for A2 on Moodle. Name your file as lastnameFirstnameA2.c (For
example, if Ritu is the first name and Chaturvedi is the last name, the file would be
called chaturvediRituA2.c).
○ An incorrect file name will result in a 10% penalty.
● The source file that you submit must include the given main function, all prototypes and
all your function definitions.
● The program you submit must compile with no warnings and run successfully for full
marks.
○ You get a zero if your program doesn’t compile.
○ There is also a penalty for warnings (5% for each category of warning).
● Penalties will occur for poor style, lack of comments, missing header comments etc.
○ Place the header comment at the top before #includes.
○ Header comment must include your full name, username, c file name, last
modified date in your header comments.
● You must follow the given function prototypes – any deviation will result in a penalty.
● You must use the main function as given – do not make any changes to it.
Steps for playing the game:
1. Ask the player for his / her full name.
This information will be used in the welcome message later.
2. The game:
We start the game with $100 Canadian dollars. A player can win up to a maximum of
$100,000 by answering 7 questions correctly. A list of 7 questions is attached – DO NOT
change the questions. The award for question 1 is 100. For all odd-numbered questions
after question1, the award is multiplied by 2; whereas for all even numbered questions,
it is multiplied by 5. So question 1 starts with an award of $100; questions 2 has an
award of $500; question 3 has $1000; question 4 has $5000, question 5 has $10,000;
question 6 has $50,000 and question 7 has an award of $100,000.
There is only 1 lifeline, which is 50 – 50. And it is offered only once in the game. This lifeline
takes away 2 choices from the current question and displays 2 just choices to the player.
Once a lifeline is used, it is not offered again to the player.
As soon as the player gives an incorrect answer, the game quits. The player wins a reduced
award, which is the award set for the previous question. For example, in a sample
scenario presented next, the player gives an incorrect answer when answering question
4, which is for $5000 – so the player wins $1000 (which is the award for question 3).
Remember to reduce the amount appropriated for odd and even questions (reduced by
half for odd questions and by 5 for even questions).
3. You must test your functions using the main function given with this assignment. You
must not change any statement or the order of statements given in main. A sample test
scenario is given below for convenience.
Sample Scenario: (Blue font is used to indicate a playerinput)
Enter your first name: Ritu
Enter your first name: Chaturvedi
*
**
***
***********************
Welcome Ritu Chaturvedi
Let us play WDWM!
***********************
***
**
*
Here is the $ 100 question:
Which of the following programming language is taught in
CIS1500 at the University of Guelph?
A. Python B. Cobra
C. C D. Java
Would you like to use a lifeline (50–50)?
Enter Y or y, N or n: x
Invalid option entered
Enter Y or y, N or n: n
Enter your FINAL ANSWER (‘A’, ‘B’, ‘C’ OR ‘D’) here: C
Very nice - You just won $ 100
Let us play the next question now
Here is the $ 500 question:
Which Canadian chain first opened in Hamilton in 1964?
A. McDonalds B. Tim Hortons
C. Wendy D. Mr. Sub
Would you like to use a lifeline (50-50)?
Enter Y or y, N or n: y
OK - here are your 2 choices after using the 50-50 lifeline
A. McDonald's
B. Tim Hortons
Reminder - You get only 1 lifeline - and you are using it now
Enter your FINAL ANSWER (‘A’, ‘B’, ‘C’ OR ‘D’) here: Z
Enter your FINAL ANSWER (‘A’, ‘B’, ‘C’ OR ‘D’) here: F
Enter your FINAL ANSWER (‘A’, ‘B’, ‘C’ OR ‘D’) here: B
Congrats - You just won $ 500
Let us play the next question now
Here is the $ 1000 question:
What is Canada's national sport?
A. Hockey B. Lacrosse
C. Hockey and Lacrosse D. Baseball
Enter your FINAL ANSWER (‘A’, ‘B’, ‘C’ OR ‘D’) here: C
Well done - You just won $ 1000
Let us play the next question now
Here is the $ 5000 question:
Which Canadian city ranks as the most educated in the country?
A. Montreal B. Ottawa
C. Vancouver D. Toronto
Enter your FINAL ANSWER (‘A’, ‘B’, ‘C’ OR ‘D’) here: D
Oops - that was incorrect. You still won $1000. Well done.
It was fun playing with you.
Function definitions to write:
# Function Prototype and Description
1 void promptPlayerForName (char fullName[50]);
Prompts the player for first name and lastname and stores their full name in fullName.
2 void printWelcomeMessage (char fullName [50]);
Prints a welcome message using the player’s full name, before the game begins (as shown in the sample
scenario). The total number of stars on lines 4 and 7 of the pattern used in the welcome message is equal to
the length of the player’s full name + 8. For example, the given full name has a length of 15, so the total
number of stars on lines 4 and 7 are 23. The other lines should have the same number of stars as shown in the
sample.
You MUST use a loop to draw his pattern.
3 int calculateCurrentAward (int questionNumber, int awardPreviousQuestion);
Calculates the award money for the current question, using the amount won for the previous question.
- award for question 1 is 100
- award for current question is times 2 of the previous amount for odd questions 3, 5 and 7
- award for current question is times 5 of the previous amount for even questions 2, 4 and 6
4 void popUpCurrentQuestion4choices (int currentAwardAmount);
Pops up the current question with initial 4 choices
5 char askPlayerForLifeLine(void);
Asks the player if they would like to use a 50 / 50 lifeline and returns the user’s response as ‘y’, ‘Y’, ‘n’ or ‘N’.
Any other response is considered invalid and the player is prompted to enter a valid response.
6 void popUpCurrentQuestion2choices (int currentAwardAmount);
Pops up the current question with 2 choices (after the player has opted for 50 / 50 lifeline).
7 char acceptPlayersFinalAnswer (void);
Prompts the player to enter the final answer for the current question as ‘A’, ‘B’, ‘C’ or ‘D’ and returns the
player’s response. Any other response is considered invalid and the player is prompted to enter a valid
response.
8 bool isCorrectFinalAnswer (char finalAnswer, int questionNumber, char
allCorrectAnswers[MAX_QUESTIONS]);
returns a true (or 1) if the final answer for the current question is correct – it returns false or 0 otherwise
9 void generateRandomGreeting (char greet[20]);
uses a random number between 1 and 5 to generate a string and store in a string variable called greet.
1 - Bravo
2 - Congrats
3 - Well done
4 - Very nice
5 - Proud of you
10 int calculateReducedAward (int questionNumber, int currentAwardAmount);
Calculates the award that a player gets when they give a wrong answer. The award they get depends on the
current question number – for an even-numbered question, it is reduced by one fifth; for odd-numbered
questions, it is reduced by half of the current award.

More products