Skip to content

Commit

Permalink
added a file that features the continue statement in an if statement.…
Browse files Browse the repository at this point in the history
… The continue statement causes current iteration of loop to end immediately.
  • Loading branch information
jesushilarioh committed Oct 17, 2016
1 parent 72c7d9b commit f58e624
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions Opt-topics/continue-statement.cpp
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;
}

0 comments on commit f58e624

Please sign in to comment.