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

A Software Company in New Jersey sells a package that retails for $99. Quantity

ID: 3593260 • Letter: A

Question

A Software Company in New Jersey sells a package that retails for $99. Quantity discounts are given according to the following table:

Quantity                              Discount

10-19                                     10%

20-49                                     20%

50-99                                     30%

100 or more                          40%

Write a program that asks the user to enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount.

Explanation / Answer

void purchaseOrder() {

int qty, disc;

float totalAmount,totalDisc,total;

printf(“Please enter how many packages you want to purchase ”);

scanf(“%d”, &qty);

if(qty >= 0)

{

switch (qty) {

case 0 … 9:                 disc = 0 ;

                                    printf(“No discounts for quantity less than 10 ”);

                                    break ;

case 10 … 19 :                        disc = 10;

                                    printf(“Discount is : %d %% ”, disc);

                                    break ;

case 20 … 49 :                        disc = 20;

                                    printf(“Discount is : %d %% ”, disc);

                                    break ;

case 50 … 99:             disc = 30;

                                    printf(“Discount is : %d %% ”, disc);

                                    break ;

default :                       disc = 40;

                                    printf(“Discount is : %d %% ”, disc);

                                    break ;
}}

else {

printf(“Quantity cannot be negative ”);

exit(0);

}

total = qty * 99;

totalDisc = (disc * total)/100;

totalAmount = total – totalDisc;

printf(“Total amount of purchase is : %d and the total discount is : %d”, totalAmount, totalDisc);

}

NOTE : GCC compilers support case ranges as a language extension

If this helps, please give a thumbs up. Good Luck!!

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