Hello, I have a homework assignment due for my Intro to Programming class, I have no idea what I am doing and wanted some help. I complete it in RAPTOR and generated the C++ code from there, but my professor doesnt want us to do it like that, he wants us to write it ourselves. Can anyone help me translate this from the RAPTOR format? I would really appreciate it.

#include <iostream>
#include <string>

using namespace std;
int main()
{
   string raptor_prompt_variable_zzyz;
   ?? password;
   ?? length;
   ?? index;
   ?? validpassword;

   while (1)
   {
      raptor_prompt_variable_zzyz ="Please enter your password:";
      cout << raptor_prompt_variable_zzyz << endl;
      cin >> Password;
      validPassword =false;
      Length =password'Length;
      if (Length<6)
      {
         cout << "Your password should be at least 6 characters long" << endl;      }
      else
      {
         Index =1;
         while (1)
         {
            if (Password(Index)>='0' && Password(Index)<='9')
            {
               validPassword =true;
            }
            else
            {
               Index =Index+1;
            }
            if (validPassword==true || Index>Length)) break;
         }
         if (validPassword==true)
         {
            cout << "Thank you, that is a valid Password!" << endl;         }
         else
         {
            cout << "Your password must include at least one digit (1-9)" << endl;         }
      }
      if (validPassword==true)) break;
   }

   return 0;
}

This is a matter of going line by line and changing the code to C++. All variables in C++ must have a type (i.e. int, char, string, etc.) and must be declared before you use them, so a good start might be to figure out what variables you need and what type they need to be. Keep in mind also that C++ is case-sensitive. validpassword and validPassword are not the same. So pick one of them for the name. Now give it a type. I see validPassword being assigned to true or false in the code, so I think we can fill in the question marks in line 11.

bool validPassword;

Now how about line 19? Look at the string library in C++. See what function we call to get the length of the string.

Line by line. There is a conversion for each line and the conversion will not require much except for syntactical changes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.