Question: Write a PHP program to calculate the payment receipt for renting a number of movies, using a conditional structure. Suppose that the rental rate depends
Write a PHP program to calculate the payment receipt for renting a number of movies, using a conditional structure.
Suppose that the rental rate depends on the number of movies rented by a customer at a time. There is a limit of renting a maximum of 20 movies at a time.
Conditions: For the first 2 movies rented, the rate is $5.50/movie. For the next 2 movies rented, the rate is $4.25/movie. For the next 3 movies rented, the rate is $3.00/movie. For any more movies rented (no more than 20), the rate is $2.00/movie.
Hence, if a customer rents 5 movies, two of those will be rented at $5.50, two for $4.25 and one for $3.00, for a total of (2*$5.50) + (2*$4.25) + $3.00 = $22.50.
1) Create a form that asks the customer for his/her name and the number of movies he/she would like to rent. On submit, display the total amount due (shown to 2 decimal places) on the same page. Check for blank and error inputs, and give appropriate error/warning messages in each case. (20 points)
2) Save the customers submitted name and number of movies rented in a flat file called lastvisitor.txt. You should overwrite this information every time someone submits the form. Use appropriate open/close, lock/unlock functions and give error messages when needed.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
