Exam 5. MUST USE LOOP FOR

  • Question 1 (80 points): The frequent flyer rewards program allows customer to earn points for every dollar spent on the flight ticket and then use rewards points for future ticket purchases. The amount and type of fare customer chooses determines how many points customer earns. For Business Fare, customers earn 12 points per dollar and for Coach Fare customers earn 10 points per dollar. For example, if the business fare ticket cost $220, customer will earn 12*220 = 2640 points for that flight.

    Write a function year_points that has one parameter, the number of flights customer purchased in one year. The function reads the ticket price for each flight and the fare indicator for each flight, the integer 1 or 2, where 1 indicates business fare and 2 coach fare. The function returns the total number of points customer earned during the year.

    Write a program that reads the number of flights customer purchased in one year. Use function year_points to find the number of points customer earmed during the year, and then determine if the customer is eligible for free domestic flight or free international flight. Use the following rule: free international flight cost 60000 points and free domestic flight cost 35000 points.

    Bonus: write a program that inputs the number of years customer is the member of the frequent flyer program, reads number of flights for each year, and finds the total number of points, the average per year and the year with the maximal number of points

  • Question 2 (20 points): For the program above write a sample input/output and explain your answer. In your sample input/output you must have at least 2 flights.