My Assignment is attached
ELI CSC 201 Unit 1 Programming Problems Worksheet Programming Problem 1 – Calculating a Number As part of the discussion forum for this unit, you will be solving a programming problem from the book. This assignment will have you calculating the chapter and the number of the programming problem that you will solve for the online discussion forum. To calculate the chapter from which you solve the programming exercise: · Divide the integer number representing your student ID by 3, consider the remainder and increment it by 3. The result you obtain represents the chapter number, and it should be either 2, 3, 4, or 5. Depending on the chapter number obtained above, consider the following rules in calculating the problem number to solve: · If the chapter number is 3, divide your student ID by 34, consider the remainder and increment it by 1. The result you obtain represents the number of the programming exercise you will solve for online discussions, which should be from chapter 3. · If the chapter number is 4 (you need to go to chapter 6), divide your student ID by 38, consider the remainder and increment it by 1. The result you obtain represents the number of the programming exercise you will solve for online discussions, which should be from chapter 6. · If the chapter number is 5, divide your student ID by 46, consider the remainder and increment it by 1. The result you obtain represents the number of the programming exercise you will solve for online discussions, which should be from chapter 5. After calculating the number of the chapter, and the number of the programming exercise to solve, ask the user to enter the page number where the specific problem is located in the textbook. Display the requirement for the programming exercise using the following format: “Please solve programming exercise … (include here the number of the exercise) from chapter … (include here the number of the chapter), from page … (include here the page number)." Grading Rubric Task Points Working solution 6 Overall usage of programming best practices 2 Total 8 Screenshots Programming Problem 2 – Vending Machine Write a program that simulates the functionality of a vending machine having the following characteristics: · The vending machine offers 5 products · The vending machine accepts coins, 1 dollar bills, and 5 dollar bills · The change is always given in coins, with maximum possible number of coins in each value: 25, 10, 5 or 1 cent. · The selections available for user are numbers from 1 to 5. · The user enters the money – simulate the action through a loop that ends when the user enters 0. Each coin, or paper bill will be read individually. · The user makes the selection, and the machine allows a maximum 4 other selections if the amount entered doesn’t cover the price of the item. · Once an item is delivered, the machine gives the change in coins. · There is no increment for the money during one selection. · The user can stop the selection at any time by entering 0 for the product selection. · If the user chooses to cancel the selection, the machine returns the initial amount in coins. · Display the outcome of the operation for each alternative you consider possible for the vending machine. · Make sure that the machine returns the correct change at all times. Use appropriate selection and repetition loops to solve the problem. Write a test program that would take at least 3 combinations of amounts entered and choices of products, and displays the results of all three trials. You can include the vending machine program as a method in the testing program. Grading Rubric Task Points Correct program written according to the requirements listed above 10 Correct testing program including three different data combinations 4 Overall usage of best practices in programming 2 Total 16 Screenshots Programming Problem 3 – Broken GPS Consider yourself driving with 60 miles/hour in a city that has only grid like streets, and your GPS is broken. The specifications of the problem are: · With (x, y) as the coordinates of the car, consider the initial position (0,0). · At each intersection, the only directions available are North, South, East or West · The GPS is broken, and it chooses the direction randomly at each intersection, which happens every 5 minutes · The assumption is that the car has the same speed at all times, including when it changes direction and turns. Write a program that calculates the direct distance from the initial point to the location point of the driver after one hour of driving (i.e. the distance between two points). Grading Rubric Task Points Working solution for the problem 10 Overall usage of programming best practices 2 Total 12 Screenshots Programming Problem 4 – Complex Numbers A complex number is defined as z=a+i*b, where a is the real part, and b is the imaginary part. In other words, in order to define a complex number, we need the two floating numbers a and b. Write methods that perform for each of the following operations with complex numbers z1 = a1 + i*b1, and z2 = a2 + i*b2: · Addition: z1 + z2=(a1+a2) + i*(b1+b2) · Subtraction: z1 - z2=(a1-a2) + i*(b1-b2) · Multiplication: z1*z2 = (a1*a2 – b1*b2) + i*(a1*b2 + b1*a2) · Division: z1/z2 = (a1*a2 +b1*b2)/(a2^2 + b2^2) + i*(b1*a2 – a1*b2)/(a2^2 + b2^2) Create a test program that asks for the real and imaginary parts of two complex numbers from the user, and displays the results of the four operations, writing the formula as shown above, and replacing the a1, a2, b1 and b2 with the numbers entered by the user. Grading Rubric Task Points Working solution for the problem 12 Overall usage of programming best practices 2 Total 14 Screenshots 1