You are required to calculate the charges for DVD rentals, where current release cost RM3.50 and all others cost RM2.50. If a customer rents several DVDs, every third one is free. The following are the output with example input shown in bold:
How many DVDs are being rented? 6
Is DVD #1 a current release? (Y/N) Y
Is DVD #2 a current release? (Y/N) N
DVD #3 is free!
Is DVD #4 a current release? (Y/N) Y
Is DVD #5 a current release? (Y/N) N
DVD #6 is free!
The total is RM12.00
Figure 1: Program Output with Example Input Shown in Bold
1
Expert's answer
2012-08-10T10:38:59-0400
C++ You are required to calculate the charges for DVD rentals, where current release cost RM3.50 and all others cost RM2.50. If a customer rents several DVDs, every third one is free. The following are the output with example input shown in bold: Figure 1: Program Output with Example Input Shown in Bold How many DVDs are being rented? 6 Is DVD #1 a current release? (Y/N) Y Is DVD #2 a current release? (Y/N) N DVD #3 is free! Is DVD #4 a current release? (Y/N) Y Is DVD #5 a current release? (Y/N) N
void main(){ printf("How many DVDs are being rented? "); scanf("%d",&num); for (i=1;i<=num;i++){ if (i%3==0) printf("DVD #%d is free!\n", i); & else { & printf("Is DVD #%d a current release? (Y/N) ", i); & scanf("%s",ans); & if ((strcmp(ans,"Y")==0)||(strcmp(ans,"y")==0)) sum+=2.5; & else sum+=3.5; & } } printf("Total: RM %f\n", sum); }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment