Homework Solution: Your program needs to store the sales price of cars purchased. You are to store the sales price NOT THE LIST PR…

    Your program needs to store the sales price of cars purchased. You are to store the sales price NOT THE LIST PRICE. Your program needs to allow a user to store up to 50,000 car sales. Once a user presses “ENTER A NEW SALE” the program will ask the following questions: What is the sticker Price of the car you are buying Are you a first time buyer Are you a veteran Are you a student Is it the last day of the month RULES of a car sale If it is the last day of the month, the car is discounted by 5% before any other discounts are applied. First buyers get a $500 credit Veterans get a 1% discount off the final price of the car Students get an extra $700 off the price. Students that are also first time car buyers get the other discounts plus another $500 off the sticker price. The program will output the following information at any time during the running of the program. The output will go to the screen. Total cars sold Average car sold price Total revenue collected Assuming the dealer marks up the final price by 5% then total revenue earned by the dealer will go up by that amount (the revenue from that sale). RULES for your program You need comments Main needs to have a switch and a bunch of function calls Main will have variables The majority of your work with be done within functions c program  

    Expert Answer

     
    /* ============================================================================ Name : cars.c =========================================================================

    Your program deficiencys to shop the sales expense of cars purchased. You are to shop the sales expense NOT THE LIST PRICE.

    Your program deficiencys to yield a user to shop up to 50,000 car sales.

    Once a user presses “ENTER A NEW SALE” the program earn entreat the subjoined questions:

    What is the sticker Expense of the car you are buying

    Are you a primeval date buyer

    Are you a proficient

    Are you a tyro

    Is it the definite day of the month

    RULES of a car sale

    If it is the definite day of the month, the car is allowanceed by 5% anteriorly any other allowances are applied.

    Primeval buyers gain a $500 credit

    Veterans gain a 1% allowance impromptu the definite expense of the car

    Students gain an extra $700 impromptu the expense.

    Students that are besides primeval date car buyers gain the other allowances plus another $500 impromptu the sticker expense.

    The program earn output the subjoined notice at any date during the ordinary of the program. The output earn go to the curtain.

    Entirety cars sold

    Average car sold expense

    Entirety income collected

    Assuming the trader marks up the definite expense by 5% then entirety income earned by the trader earn go up by that unite (the income from that sale).

    RULES manage your program

    You deficiency comments

    Main deficiencys to keep a switch and a group of administration calls

    Main earn keep variables

    The eldership of your toil with be executed among administrations

    c program

     

    Expert Counter-argument

     

    /*

    ============================================================================

    Name : cars.c

    ============================================================================

    */

    #include <stdio.h>

    #include <stdlib.h>

    transport definitedaymonths(transport p){

    transport disc_price=p-p*0.05;

    return disc_price;

    }

    transport primevalbuyers(transport p){

    transport fantastic_expense = p – 500;

    return fantastic_price;

    }

    transport vaterans(transport p){

    transport disc_expense = p-p*0.01;

    return disc_price;

    }

    transport tyros(transport p){

    return p-700;

    }

    transport primeval_time_student(transport p){

    return p-1200;

    }

    int main(void) {

    char x=’n’,v = ‘n’,s=’n’,ftb=’n’,ldm=’n’; /* x = manage fantastic sale

    v = vateran hinder

    s = tyro hinder

    ftb = primeval date buyer hinder

    ldm definite day month hinder */

    transport sp,cp[50000],sum=0,avg=0; // sp = sticker expense cp[]=shop definite car expense

    int i=0;

    printf(“Do You absence to Enter a Fantastic Sale ?n Press Y manage yes or N manage no:n”);

    scanf(“%c”,&x);

    if(x==’Y’||x==’y’){

    int c=0;

    printf(“What is the sticker expense of car you are buying? :n”);

    scanf(“%f”,&sp);

    printf(“Are you a primeval date buyer? :n”);

    scanf(“%c”,&ftb);

    printf(“Are you a proficient? :n”);

    scanf(“%c”,&v);

    printf(“Are you a tyro? :n”);

    scanf(“%c”,&s);

    printf(“Is it definite day of month? :n”);

    scanf(“%c”,&ldm); // manage converting to switch instance produce contrariant instance using conditions

    if(ftb==’Y’||ftb==’y’){

    if(s==’Y’||s==’y’){

    c=1;

    if(ldm==’Y’||ldm==’y’){

    c=2;

    }

    }

    if(v==’Y’||v==’y’){

    c =3;

    if(ldm==’Y’||ldm==’y’){

    c=4;

    }

    }

    }

    else{

    if(s==’Y’||s==’y’){

    if(ldm==’Y’||ldm==’y’){

    c=5;

    }

    else

    c=6;

    }

    if(v==’Y’||v==’y’){

    c =7;

    if(ldm==’Y’||ldm==’y’){

    c=8;

    }

    }

    } // Apply switch instance as per contrariant conditions

    switch(c){

    instance 1: cp[i]=first_time_student(sp);

    break;

    instance 2: cp[i]=students(lastdaymonths(sp-500));

    break;

    instance 3: cp[i]=vaterans(firstbuyers(sp));

    break;

    instance 4: cp[i]=vaterans(firstbuyers(lastdaymonths(sp)));

    break;

    instance 5: cp[i]=students(lastdaymonths(sp));

    break;

    instance 6: cp[i]=students(sp);

    break;

    instance 7: cp[i]=vaterans(sp);

    break;

    instance 8: cp[i]=vaterans(lastdaymonths(sp));

    break;

    default: printf(“Default instance”);

    }

    i++;

    }

    printf(“n Entirety cars sold: %d”,i+1); //print entirety no of cars sold

    int j;

    for(j=0;j<=i;j++){

    unite = unite +cp[i];

    }

    avg = unite/(i+1);

    printf(“Average car sold expense : %f”,avg);

    printf(“n entirety income earned %f”,sum+sum*0.05);

    return 0;

    }