-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a file that features the continue statement in an if statement.…
… The continue statement causes current iteration of loop to end immediately.
- Loading branch information
1 parent
72c7d9b
commit f58e624
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//***************************************************** | ||
// This program calculates the charges for DVD rentals. | ||
// | ||
// By: JESUS HILARIO HERNANDEZ | ||
// Last modified: October 17th, 2016 | ||
//***************************************************** | ||
#include <iostream> | ||
#include <iomanip> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int dvdCount = 1; // DVD counter | ||
int numDVDs; // Number of DVDs rented | ||
double total = 0.0; // Accumulator | ||
char current; // Current release, Y or N. | ||
|
||
// Get the number of DVDs. | ||
cout << "How many DVDs are being rented? "; | ||
cin >> numDVDs; | ||
|
||
// Determine the charges. | ||
do | ||
{ | ||
if ((dvdCount % 3) == 0) | ||
{ | ||
cout << "DVD #" << dvdCount << " is free!\n"; | ||
continue; // Immediately start the next iteration | ||
} | ||
cout << "Is DVD #" << dvdCount; | ||
cout << " a current release? (Y/N)"; | ||
cin >> current; | ||
if (current == 'Y' || current == 'Y') | ||
{ | ||
total += 3.50; | ||
} | ||
else | ||
{ | ||
total += 2.50; | ||
} | ||
} while (dvdCount++ < numDVDs); | ||
|
||
// Display the total.] | ||
cout << fixed << showpoint << setprecision(2); | ||
cout << "The total is $" << total << endl; | ||
return 0; | ||
} |