You are required to develop a program that calculates 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 continue statement is used to skip the part of the loop that calculates the charges for every third DVD. The following are the program output with example input shown in bold:
Figure 1: Program Output with Example Input Shown in Bold
END OF ASSIGNMENT QUESTION
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
1
Expert's answer
2012-02-07T15:41:39-0500
#include <iostream>
#define RM 2.5 #define CurRM 3.5
using namespace std;
void main() { int count = 0; float total = 0; char c; cout << "How many DVDs are begin rented? "; cin >> count;
for(int i = 0; i < count; i++) { & if ((i+1)%3 == 0) & { & cout << "DVD #" << i+1 << " is free!\n"; & continue; & } & cout << "is DVD #" << i+1 << " a current release? (Y/N) "; & cin >> c; & if(c == 'Y' || c == 'y') & total += CurRM; & else if(c == 'N' || c == 'n') & total += RM; }
"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