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