Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

\"Introduction\" Computer science code. The security code is acquired via the tw

ID: 3758429 • Letter: #

Question

"Introduction" Computer science code.

The security code is acquired via the two functions getSecCodeA, and getSecCodeB. Both functions use the technique shown in lecture to extract a substring from the DUMP, and convert it into an integer value before returning it.

The code is validated with three conditions. The first five digits of the ten digit security code must be a prime number. This can be considered as fitting key 1.

The function fitsKey1 uses this criteria in returning a true or false value. One solution to this code implementation is provided and shown in the graphic above.

The function fitsKey2 uses the same criteria as project 1. Is the 5 digit integer passed into the function evenly divisible by KEY2? If so, it returns a true value if not it returns false.

The function fitsKey3 compares KEY3 to the length of the DUMP. If there is not an exact match, it returns a false value, and returns true otherwise.

The function validateCode, uses the three fitsKey functions to determine the validity. If all three return true, then this function returns a true value. Otherwise, it returns false.

Explanation / Answer

working c++ code

#include<iostream>
#include<string>
bool fitskey1(int n)
{
   int flag;
   for(int i=2;i<=n/2;++i)
{
if(n%i==0)
{
flag=1;
break;
}
}
if (flag==0)
return 1;
else
return 0;
}
bool fitskey2(int n)
{
   if(n%50 == 0)
   return 1;
   else
   return 0;
}
bool fitskey3(string st)
{
   if (st.length() == 1)
   return 1;
   else
   return 0;
}
bool validate(int n,int m,string str)
{
   bool a,b,c;
   a=fitskey1(n);
   b=fitskey2(m);
   c=fitskey3(str);
   if(a==1 && b==1 && c==1)
   return 1;
   else
   return 0;
  
}

int main()
{
      
}