#include <iostream>
#include <string> 
using namespace std;

int main()
{
		// Variable declarations allowing us to calculate 
		string fullName;
		int weeklySalary;
		int weeks; 
		string age; 
		int option; 
		int actualage; 
		int earnings; 
		double savingsPercentage;
		double percentage; 
		int retirementage; 
		double total;
		cout << "What is your name? "; 
		getline(cin, fullName); 
		cout << "How old are you? ";
		cin >> age;
		cin.ignore(); // Removes the control character...
		cout << "Please select an option: " << endl;  // Main menu allowing selection of option.
		cout << "\t(1) Number of years to retirement" << endl;
		cout << "\t(2) Amount earned between now and retirement" << endl;
		cout << "\t(3) Amount saved at retirement" << endl;
		cout << "\t(4) Exit" "(do nothing)" << endl; 
		cin >> option; 
		cin.ignore(); // Removes the control character...
		do
		{
			if	(option == 1)
			cout << option << " "; 
		}
			// The code in Case 1 calculates the Number of years you have.  
			cout << "You have " << actualage << " years until retirement." << endl; 
			cout << "Please select an option: " << endl;  // Main menu allowing selection of option...
			cin >> option; 
			cin.ignore(); // Removes the control character...
		do
		{	
		else if (option == 2)
		{
		cout << option << " "; 
		}
			// The code in case 2 calculates the Amount Earned between now and retirement by age.
			cout << "How much do you make per week in dollars? "; 
			cin >> weeklySalary;
			cin.ignore(); // Removes the control character...
			weeks = (52 * actualage); 
			earnings = (weeks * weeklySalary);   
			cout << "You will earn " "$"<< earnings << " between now and retirement." << endl; 
			cout << "Please select an option: " << endl;  // Main menu allowing selection of option...
			cin >> option; 
			cin.ignore(); // Removes the control character...
		do 
		{
		else if (option == 3)
		cout << option << " ";  
		} 
			// The code in case 3 calculates the Amount Saved at Retirement taking into account the savings rate...
			cout << "How much do you make per week in dollars? "; 
			cin >> weeklySalary;
			cin.ignore(); // Removes the control character...
			weeks = (52 * actualage); 
			earnings = (weeks * weeklySalary); 
			cout << "What percentage will you save? ";
			cin >> savingsPercentage;
			cin.ignore(); // Removes the control character...
			percentage = (savingsPercentage / 100); 
			total = (percentage * earnings);
			cout <<	"You will have " << total << " saved when you retire << endl;    
			cin >> option; 
			cin.ignore(); // Removes the control character...
		do
		{
			else if (option == 4)
			cout << option << " "; 
		}	
			cout << "Thanks for using our program." << endl; 		

}

"I am trying to use a Do While Loop per the requirements"

Edited 5 Years Ago by WaltP: Added CODE Tags -- please use them, and do not use TEX tags.

why dont u use a
switch(option)
case 1:
Numbers of year...
break;
case 2:

and keep going
much easier to debug

We could help if you put the code within a [ CODE]***
[/code] in the advanced editor so we can see it more clearly

Edited 5 Years Ago by L3gacy: n/a

Each do loop needs a while condition, such as:

bool done = false;
do
{
   // Stuff to do
   if (no_more_stuff_to_do)
   {
       done = true;
   }
}
while (!done);

// Or

while (!done)
{
    // Stuff to do
    if (no_more_stuff_to_do)
    {
       done = true;
    }
}
This article has been dead for over six months. Start a new discussion instead.