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

Results must be in two decimal places Problem Description Keith’s Sheet Music ne

ID: 3639451 • Letter: R

Question

Results must be in two decimal places

Problem Description

Keith’s Sheet Music needs a program to implement its music teacher’s discount policy. The program is to prompt the user to enter the purchase total and to indicate whether the purchaser is a teacher. The store plans to give each customer a printed receipt, so your program is to display a nicely formatted output receipt. Music teachers receive a 10% discount on their sheet music purchases unless the purchase total is $100 or higher. In that case, the discount is 12%. The discount calculation occurs before addition of the 5% sales tax. Here are two sample outputs – one for a teacher and one for a nonteacher.

Sample Run

For a teacher:

Is customer a teacher (Y/N ) ? Y
Enter total purchases: 122

Total purchases $122.00
Teacher’s discount (12%) 14.64
Discounted total 107.36
Sales tax (5%) 5.37
Total $112.73


For a nonteacher:

Is customer a teacher (Y/N ) ? N
Enter total purchases: 24.9

Total purchases $24.90
Sales tax (5%) 1.25
Total $26.15

Explanation / Answer

#include main() { float pur_total,disc=0.0; char t; printf("Is customer a teacher (Y/N ) ?"); scanf("%c",&t); printf("Enter total purchases: $"); scanf("%f",&pur_total); if(t=='Y')/*Teacher's Calculations*/ { printf(" Total Purchases $%.2f",pur_total); if(pur_total>=100) { disc=0.12;/* Teacher's Discount - 12%, if purchases 100 or higher*/ } else { disc=0.10;/* Teacher's Discount - 10%, Otherwise*/ } printf(" Teacher's discount(%.2f%)$%.2f",disc*100,disc*pur_total); pur_total=(1-disc)*pur_total;/*Teacher's discounted total is updated here*/ printf(" Discounted total $%.2f",pur_total); printf(" Sales tax(5%) $%.2f",0.05*pur_total); pur_total=(1+0.05)*pur_total; printf(" Total $%.2f",pur_total); } else/*Non-Teacher Calculations*/ { printf(" Total Purchases $%.2f",pur_total); printf(" Sales tax(5%) $%.2f",0.05*pur_total); pur_total=(1+0.05)*pur_total; printf(" Total $%.2f",pur_total); } }
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