Files
Microsoft Word - miilionnaire.docx Assignment 1: millionEh (Marked out of 100, 7% weight) Topics covered: Assignment, Input/Output, Conditional statements (if / else, if, nested if, multi- branch nested if, switch), Simple while / for loops. Do not use arrays, strings, files and functions for this assignment. 1.0 The task In this assignment, you have to program a game called “millionEh”. 1.1 Ask the player for their year of birth entered as a single integer with 4 digits (e.g., 1999). Print a welcome message that displays the player’s lucky number. This lucky number is calculated by adding the individual digits in the player’s year of birth (e.g., if the year of birth entered is 1999, then the player’s lucky number is 28). See the sample scenario for an example of a welcome message. The welcome message is displayed between two lines of 25 stars each. 1.2 The game: 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 in a file called questionsSet.txt – use the questions from this file, 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. Basically, question 1 starts with an award of $100; question 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. For each question, the player is prompted to enter the final answer for the current question as ‘A’, ‘B’, ‘C’ or ‘D’. For each correct answer, your program must generate a random greeting (e.g. Bravo) and display a message such as “Bravo, you just won $ 500”. Use a random number between 1 and 5 to generate one of the following greetings. 1 - Bravo 2 - Congrats 3 - Well done 4 - Very nice 5 - Proud of you There is only 1 lifeline, which is 50 – 50. And it is offered only once in the game. After a question and its choices are displayed, the player is asked if they would like to use a 50 / 50 lifeline – the only acceptable responses from the player are ‘y’, ‘Y’, ‘n’ or ‘N’. This lifeline takes away 2 choices from the current question and displays just 2 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 with a final message such as “Oops - that was incorrect. You still won $1000. Well done. It was fun playing with you” as shown in the scenario below. If the player gives an incorrect answer for the first question, then the game quits with a message “Oops - that was incorrect. You won zero dollars, but it was fun playing with you”. Note that in case an incorrect answer is given for every question other than question 1, the player wins a reduced award, which is the award set for the previous question (in case of question 1, the award is zero dollars). For example, in a sample scenario presented next, the player gives an incorrect answer when answering question 4, award for which is $5000 – so the player wins $1000 (which is the award for question 3). Remember to reduce the amount appropriately for odd and even questions– for an even-numbered question, it is reduced by one fifth of the current award; for odd- numbered questions, it is reduced by half of the current award. For example, if the player is at question 4 (that has an award of $5000) and given an incorrect response, then the game ends by giving the player an award of $1000 (i.e. 1/5th of $5000). A sample test scenario is given for convenience in section 3.0. 2.0 Extras – 10% The above task given in 1.0 can fetch you 90% grade in this assignment. Complete the following for the additional 10%. • Note that the player is prompted to enter the year of birth as a single integer with 4 digits yyyy (e.g. 1999). It is invalid in this game to enter less than 4 digits for year of birth (e.g. 99 is invalid). Add code so that the user is repeatedly asked to enter the year of birth as yyyy, until a valid year of birth is entered. • Note that in the game, any response other than ‘A’, ‘B’, ‘C’, or ‘D’ for a question is considered invalid. You must add code so that player is prompted to enter a valid response until a valid response is entered. • Note that there is only 1 lifeline in this game as explained in section 1.0. If the player chooses to use a lifeline, then the only acceptable responses from the player are ‘y’, ‘Y’, ‘n’ or ‘N’. Any other response is considered invalid and the player is prompted to enter a valid response until a valid one is entered A sample test scenario is given for convenience in section 3.0. The messages you use in your code may not be exactly as shown. For example, it is alright to change the message ‘Would you like to use a lifeline (50–50)?’ to some other message that has the same meaning (e.g. ‘Ready to use a lifeline?’). As mentioned in the beginning, DO NOT change the question text for any question. 3.0 Sample Scenario: (Blue font is used to indicate a player input) Enter your year of birth (yyyy): 1999 ************************* Welcome - Let us play millionEh! Your lucky number is 28 ************************* Question 1: Here is the $100 question: Which one of the following programming languages is taught in CIS1300 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 Question 2: 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 Question 3: 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 Question 4: 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. 4.0 Submission Instructions ● Submit a single C file containing your function definitions only. To submit, upload your C file to the submission box for A1 on moodle. Name your file as lastnameFirstnameA1.c (For example, if Ritu is the first name and Chaturvedi is the last name, the file would be called chaturvediRituA1.c). Incorrect file name will result in penalty. ● Incorrect format of submitted files will result in automatic zero. (Must be a valid .c file) ● 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 unique warning). ● Penalties will occur for missing style, comments, header comments etc. ● DO NOT use global variables. Use of any global variables will result in automatic zero. ● DO NOT use goto statements. Use of any goto statements will result in automatic zero. ● Use the template given below for header comment. /!\ Note: The file name, student name and email ID must be changed per student. /************************chaturvediRituA1.c************** Student Name: Ritu Chaturvedi Email Id: ritu Due Date: October 6th Course