Question: The maximum possible score is 15 marks. Late submissions will not be accepted. The assignment is to be completed individually, i.e., every student must turn

The maximum possible score is 15 marks. Late submissions will not be accepted. The assignment is to be completed individually, i.e., every student must turn in his or her own solutions. Students are allowed to discuss solution strategies with other students but they are not allowed to copy each others' answers. 1. In Lecture 1, we saw a C program called GuessNumber.c that generates a random integer between 1 and 1000 and asks the user to guess that number. Modify the program so that at the end of each round, it also prints the number of guesses made by the user to reach the answer as well as the best score so far, i.e., the minimum number of guesses used in any round since the program was started. The source code of the original version of GuessNumber.c can be found in: https://github.com/pdeitel/CHowToProgram8e/archive/master.zip under examples/ch01/GuessNumber/GNU/randomized version) (3 marks) 2. A person in retirement deposits 360,000 HKD in a savings account that pays 4% interest at the end of each year. The person withdraws money from the account once a year, immediately after the interest has been added. He withdraws 50,000 HKD at the end of the first year, and in the following years, increases the withdrawn amount according to the inflation rate. The inflation rate is constant and equal to 2%; in other words, 51,000 HKD will be withdrawn in year 2, 52, 020 HKD in year 3, etc. A withdrawal fails if it is larger than the account's current balance. Write a C program that calculates and prints the number of years until the first failed withdrawal will occur. (4 marks) 3. Write a C program that prints a calendar for one month, formatted as below. It should ask the user for the number of days in the month and the weekday of the first day of that month. (4 marks) Example: Please input the number of days: 30 Please input the starting day (1 = Monday, 2 = Tuesday, ..., 7 = Sunday): 3 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 4. Write a C program that computes the correct change to return to a customer using cash to pay for snacks and soft drinks from a vending machine. Coins in 50 cents, 1 dollar, 2 dollars, 5 dollars, and 10 dollars denominations are available. The number of coins to be returned to the customer should be minimized. First, let the program display the amount that the customer has to pay. Here, let the program choose an amount from {$0.50, $1.00, $1.50, ..., $19.50, $20.00} at random. Next, let the program take as input the amount of cash that the customer inserted into the vending machine. Finally, let the program display the number of 50-cent, 1-dollar, 2-dollar, 5-dollar, and 10- dollar coins to be returned to the customer. In case the amount paid by the customer is not enough then the program should give an error message. As an example, if the cost is $5.50 and the customer pays $10 then the change should consist of one 50-cent coin and two 2-dollar coins. (4 marks)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
