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

C Programming #include <stdio.h> NerdMart’s Department store is having a BoGoHo

ID: 2247760 • Letter: C

Question

C Programming

#include <stdio.h>

NerdMart’s Department store is having a BoGoHo (Buy One, Get One Half Off) sale. The store manager wants an application that allows the salesclerk to enter the prices of two items. The application should calculate and display the total amount the customer owes. The half-off should always be taken on the item having the lowest price. For example, if the two items cost $24.99 and $10, the half-off would be taken on the $10 item, and the message box would indicate that the customer saved $5.00.

Create a showHeader() function that displays a header and explains the BoGoHo promotion.

The main() function will call the showHeader() function and then ask the user to enter two prices. It will determine which price is the lowest and calculate half-off the lower priced item. It will also calculate the amount of tax (at 6%). Main() should display the cost of each item, the amount discounted, the total cost of items, the sales tax, and the total price due.

Sample run:

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

Welcome to NerdMart's Department Store

$$$$$$$$$$ BoGoHo $$$$$$$$$

Buy One item at full price

Get One item at Half Off

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

Enter the price of the first item:

24.99

Enter the price of the second item:

33.24

Price of first item: $24.99

Price of second item: $33.24

Discount: $12.50

Total cost for items: $45.74

Total tax due: $ 2.74

Total price: $48.48

Explanation / Answer

#include <stdio.h>

int main(){

printf("Welcome to NerdMart's Department Store BoGoHo Buy One item at full price Get One item at Half Off ");

double i1,i2;

printf("Enter price of the first item: ");

scanf("%lf",&i1);

printf("Enter price of the second item: ");

scanf("%lf",&i2);

printf("Price of the first item: $%lf ",i1);

printf("Price of the second item: $%lf ",i2);

double discount;

if(i1 > i2){

discount = i2/2;

}else{

discount = i1/2;

}

printf("Discount: $%lf ",discount);

double tot;

tot = i1+i2-discount;

printf("Total cost for items: $%lf ",tot);

double tax = 0.06*tot;

printf("Total tax due: $%lf ",tax);

printf("Total price: $%lf ",tot+tax);

return 0;

}