Hi, thanks for your time.
I’m having trouble writing a program.
I want to write a C++ program that gives the new ID for a 4-digit integer entered from the keyboard.
The new ID is formed in the following procedure:
The last four digits of a social security number (SSN) will have a new digit for each.
The new digit for the first digit is figured out by timing it by 4;
if the product is greater than 9, add its digits together.
The new value for the second digit is figured out by timing it by 3.
if the product is greater than 9, add its digits together.
The new value for the third digit is figured out by timing it by 2.
if the product is greater than 9, add its digits together.
The new value for the fourth digit is figured out by timing it by 1.
If any of the new digits is 0, change it to 9.
All the four new digits are then added up to have a total, which is
then used to time to the entered 4-digit SSN to give the new encrypted ID.
For example, with the entered four digits 2620, the new ID will be 78600
because 2*4 = 8, 6*3 = 18 = 9, 2*2 = 4, 0*1 = 0 = 9, and 8+9+4+9 = 30, and then 30*2620 = 78600.
This is what I have so far but I know its not correct—->
#include<iostream>
using namespace std;
int main()
{
int input, num1, num2, num3, num4;
cout << "Please enter a 4-digit integer : ";
cin >> input;
num1 = (input/1000) % 10;
num2 = (input/100) % 10;
num3 = (input/10) % 10;
num4 = input % 10;
cout << "The Id will be : " << ((num1 * 4) + (num2 * 3) + (num3 * 2) + (num4 * 1)) * input << endl;
return 0;
}
Also, Here is the set of data for testing:
last-4 digits of SSN: 9578, new ID: 268184
last-4 digits of SSN: 0149, new ID: 4321
last-4 digits of SSN: 1039, new ID: 29092
last-4 digits of SSN: 0004, new ID: 124
last-4 digits of SSN: 9999, new ID: 359964
last-4 digits of SSN: 0023, new ID: 575
THANKS FOR YOUR HELP!!!!!!!
I’m using Microsoft Visual C++ 2008