Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Name: Date: Movie Rental Progranm Write a program for a movie rental business. Y

ID: 3902173 • Letter: N

Question

Name: Date: Movie Rental Progranm Write a program for a movie rental business. Your program will determine the total amount a customer owes, less any discounts. It will consist of several functions. You must ONLY use the functions specified in the manner in which they are to work. Your main() function will ask the user their name and whether or not they are a repeat customer. If they are a repeat customer then you will call a function called getHistorylnformation that will ask for the tota number of movie rentals and the number of referrals to date for each quarter last year. This informat needs to be stored in an array in main). Your main) function will then call the getCurrentRentals() function which will get the total number of rentals that the customer is currently renting. Your main() function will then call a getDiscounts 0 function that will get the total discounts for the customer. The displayTotals() function will then calculate the current rental total, the total discount amounts (rental and referral), and the total amount due will then display the four values The main() function will then ask if there is another customer and if so repeat the process The getHistoryinformation() will ask for the total number of movies the customer rented for each quarter of the previous year and will ask for the number of referrals the customer had for each quarter last year (see sample output.) Be sure to validate the data so that a negative number cannot be entered. If there a negative value, produce and error message and allow them to input the number again. Remember these valid values are stored in an array in main() The getCurrentRentals) function will ask for the total number of movies that the customer is renting for the day. The customer cannot rent more than 5 movies at a time. If they do the will receive a message stating that fact. Your function should also validate the data so that a negative number of rentals are not allowed. There should also be an error message for this. Allow the user to continue to answer this question until valid and return a valid answer (See sample output.) The getDiscounts() function will determine and return the discount based on the number of movie rentals not including what they are renting today. If the customer has rented at least one movie, then their discount is 10%, if the customer has rented more than 10 movies, then their discount is 15%, if the customer has rented more than 25 movies, then their discount is 25%. The do not get a discount if they have never rented any movies in the past. The getDiscounts() function will also determine additional discount based on the number of referrals to date. You must use a switch statement to determine the discount. There is a 5% discount for 1 referral, 10% for 2 referrals, 15% for 3 referrals, 20% for 4 referrals and 25% for any referrals over 4. referral discount is also to be returned to main() They do not receive a discount for no referrals. The The displayTotals!) function wil must use a defined constant. Please note that the discounts are calculated separately and ll calculate and print the totals. The regular cost of each movie is $3.00 and are percentages of the subtotal. The following should be displayed by your function. "Your current rental total is xx.x and "Yo ur current rental discount is Sxx.xx", and "Your current referral discount is Sxx.x", and "Your current total due is Soxx. The amounts will then be followed by "Enjoy your movie! " (Please see output.)

Explanation / Answer

#include<stdio.h>

#define REGULAR_MOVIE_RENTAL 3.00

void getHistoryInformation(int a[], int b[]){
     int i;
     for (i = 0; i<4; i++){
        while(1){
           printf("Enter number of rentals Q%d last year: ",i+1);
           scanf("%d",&a[i]);
           if (a[i] < 0)
              printf("Error:Negative value ");
        }
        while(1){
           printf("Enter number of referals Q%d last year: ",i+1);
           scanf("%d",&b[i]);
           if (b[i] < 0)
              printf("Error:Negative value ");
        }
     }
}

int getCurrentRentals(){

    int n;
    while(1){
       printf("Enter number of current rentals: ");
       scanf("%d",&n);
       if (n < 0 || n >5){
          printf("Error:valid values are 1-5 ");
       }
       else
          break;
    }
    return n;
}

void getDiscounts(int r[], int rf[], double d[]){

    int sum1 = 0;
    int sum2 = 0;
    int i;
    for (i = 0; i<4; i++){
        sum1 = sum1 + r[i];
        sum2 = sum2 + rf[i];
    }
    if (sum1 > 25)
       d[0] = 0.25;
    else if (sum1 > 10)
       d[0] = 0.15;
    else if (sum1 > 0)
       d[0] = 0.10;

    switch (sum2) {
        case 1 : d[1] = 0.5;
                 break;
        case 2 : d[1] = 0.10;
                 break;
        case 3 : d[1] = 0.15;
                 break;
        case 4 : d[1] = 0.20;
                 break;
        case 5 : d[1] = 0.25;
                 break;

    }

      
        
}

void displayTotals(double ct, double rd, double rfd){

    printf("Your current rental total is $ %.2lf ", ct);
    printf("Your current rental discount is $ %.2lf ", rd);
    printf("Your current referal discount is $ %.2f ", rfd);
    ct = ct - rd - rfd;
    printf("Your current total due is $ %.2f ", ct);
}

int main(){

   int rentals[4];
   int referals[4];
   double discount[2];
  
   getHistoryInformation(rentals,referals);
   int n = getCurrentRentals();
   double currentTotal = n * REGULAR_MOVIE_RENTAL;
   getDiscounts(rentals,referals,discount);
   double rentalDiscount = discount[0] * currentTotal;
   double referalDiscount = discount[1] * currentTotal;
   displayTotals( currentTotal, rentalDiscount, referalDiscount);
   return 0;
   
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote