63 088
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #11914 in C++ for azreen

Question #11914
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
Expert's answer
# include<iostream.h>
# include<conio.h>
# include<string.h>

char ans[1];
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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions