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


int main()
{
    string password_var;
    bool validPass;
    int Length_Of;

    
    while (1)
    {
        cout << "Please enter a password.\n";
        cin >> password_var;
        validPass = false;
        Length_Of = password_var.size();
        if (Length_Of < 7)
        {
            cout << "Passwords must be at least 7 characters long.\n";
            continue; // you don't need to go further in the loop.
        }
        int i = 0;
        while (1)
        {
        	cout << password_var[i];
            if ( (password_var[i] >= '0'&&password_var[i] <= '9') 
                 || (password_var[i] == '$')
        		)
            {
                validPass = true;
            }
            else
            {
                i = i + 1;
            }
            // beware of assignment '=' and comparison '=='
            if (validPass == true || i >= Length_Of) 
                break;
        }
        if (validPass == true)
        {
            cout << "Thank you, that is a valid password.\n";
        } // add the closing brace.
        else
        {
            cout << "Passwords must include a digit or a dollar sign(0-9,$).\n";
        }
        if (validPass == true)
            break;
    }
    return 0;
}
