You will start generating a password by performing some elementary operations on the day, month and year entered by the user. Then the program will generate a sequence of characters based on the information computed.
More precisely, your program will compute 8 integers and will use each one of these integers to produce a letter. For instance, 0 stands for A, 1 for B, and so on, 25 corresponding to Z. If the number is greater than 25, then we can mod the number by 26 to get a suitable value between 0 and 25. For example, the value 35 corresponds to the same letter as 35 mod 26 = 9 which corresponds to the letter J.
The 8 integral values will be (in this order)
1. The sum of the day, month, and year
2. The factorial of the month (the factorial of an integer n is the product of all the integers between 1 and n. E.g. factorial of 5 = 5x4x3x2x1 = 120)
3. The largest divisor of the year (different from the year itself). E.g. the largest divisor of 2007 is 669.
4. The sum of all the divisors of the day (different from the day). E.g. the divisors of 20 (different from 20) are 1, 2, 4, 5, 10 and their sum is 22. Note, 1 has no divisor different from 1 itself, so the sum should be zero, in this case.
5. The result of the transformation f (explained in the following) applied month times in a row to the year. The transformation f sends a positive integer n to n/2 if n is even and to 3n+1 if n is odd. So if the year is 2007, we see that f(2007) = 6022. If the month is 1 we stop there. Otherwise we apply f again to 6022. We see that f(6022) = 3011 and we stop if the month is 2. And so on. If the month is 5, the value generated should be 13552, since f(3011) = 9034, f(9034) = 4517 and f(4517) = 13552.
6. The sum of all the digits entered. E.g. if the date is 20 05 2007, the value should be 2 + 5 + 2 + 7 = 16.
7-8. The last 2 values should be obtained by reading the year backwards and splitting the result into 2 parts. E.g. if the year is 1987, the last two values should be 78 and 91. If the year is 2007, the last two values should be 70 and 2.
ANY HELP AT ALL IS MUCH APPRECIATED, THANK YOU!!
I AM AT THE END OF MY TETHER!!
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
/*This programme is designed to generate a seemingly random password that
corresponds to a date entered by the user. Enter any date you wish and behold
as the programme returns a character password for you. Enjoy...*/
int factorialOfMonth(int);
//prototype of function to find the factorial of the month
int largestDivisorOfYear(int);
//prototype of function to find the largest divisor of the year (not the year itself)
int sumOfDivisorsOfDay(int);
//prototype of function to fin the sum of the divisors of the day
int sumOfDigitsEntered(int);
//prototype of the function to find the sum of all digits entered
int yearBackwards(int);
//prototype of function to reverse the year and split into two integers
int main() //main function of programme
{
int day, month, year; //initialised the variables, day, month and year
cout << "Enter a date (dd mm yyyy): " << flush; //asks for user input
cin >> day >> month >> year; //user inputs date
int n = (day + month + year); //declares int n as the day + month + year
cout << n << endl; //outputs the above addition
switch (letter)
{
case 0:
cout << "A" <<;
break;
case 1:
cout << "B" <<;
break;
case 2:
cout << "C" <<;
break;
case 3:
cout << "D" <<;
break;
case 4:
cout << "E" <<;
break;
case 5:
cout << "F" <<;
break;
case 6:
cout << "G" <<;
break;
case 7:
cout << "H" <<;
break;
case 8:
cout << "I" <<;
break;
case 9:
cout << "J" <<;
break;
case 10:
cout << "K" <<;
break;
case 11:
cout << "L" <<;
break;
case 12:
cout << "M" <<;
break;
case 13:
cout << "N" <<;
break;
case 14:
cout << "O" <<;
break;
case 15;
cout << "P" <<;
break;
case 16:
cout << "Q" <<;
break;
case 17:
cout << "R" <<;
break;
case 18:
cout << "S" <<;
break;
case 19:
cout << "T" <<;
break;
case 20:
cout << "U" <<;
break;
case 21:
cout << "V" <<;
break;
case 22:
cout << "W" <<;
break;
case 23:
cout << "X" <<;
break;
case 24:
cout << "Y" <<;
break;
case 25:
cout << "Z" <<;
break;
}
system("pause");
return 0;
} //end of main function
int factorialOfMonth(int month)
{
int i, factorial = 1;
for (i=1; i<=month; i++)
{
factorial = factorial * i;
}
return factorial;
}
//definition of integral function to compute the factorial of the month
int largestDivisorOfYear(int year)
{
int divisor = year;
while (year % divisor != 0)
{
divisor--;
}
return divisor;
}
//definition of function to retutn the largest divisor of the year
int sumOfDivisorsOfDay(int day)
{
int sum = 0, num = day, divisor = (day/num);
if ((day % num) == 0)
{
sum += divisor;
}
day--;
if (day == 1);
return sum;
}
//definition of function to return the sum of the divisors of the day entered.
int yearBackwards(int argc, char**argv)
{
int q;
int numDigitsOfB;
int divisor;
int a,b;
numDigitsOfB = 2;
divisor = (int)pow(10.0,(double)numDigitsOfB);
q = 1234567;
a = q / divisor;
b = q % divisor;
return("%d %d %d %d %d\n",numDigitsOfB,divisor,q,a,B);
}

New Topic/Question
Reply




MultiQuote



|