# Answer to Question #12884 in C++ for shalennee

Question #12884
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
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

# include<iostream.h>
# include<conio.h>
# include<string.h>

char ans;
float sum = 0;
int num, i;

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);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!