60 337
Assignments Done
98%
Successfully Done
In April 2018

Answer to Question #6380 in C++ for diviyah

Question #6380
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
Expert's answer
#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;
}

cout << "\nThe total is RM " << total << endl;
}

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