4E PROGRAMSExperimental scoring rubric:
You will receive one point for attempting the program in good faith. You will receive one point for each successful test you are able to run. Specific overrides to pass those individual tests will not be accepted. |
|
Reverse Reverse
Write a program that reads in a person's name on a single line and reverses the first and last names, no matter how many middle names they have.
TEST DATA:
INPUT
Jacopo Peterman
OUTPUT
Peterman Jacopo
INPUT
John Jacob Jingleheimer Schmidt
OUTPUT
Schmidt Jacob Jingleheimer John
Write a program that reads in a person's name on a single line and reverses the first and last names, no matter how many middle names they have.
TEST DATA:
INPUT
Jacopo Peterman
OUTPUT
Peterman Jacopo
INPUT
John Jacob Jingleheimer Schmidt
OUTPUT
Schmidt Jacob Jingleheimer John
NationalID: 1 to 6 points
The Republic of Pascalia has decided to implement a national ID number for its citizens. The format of this ID number is as follows: YYYY-MM-DD-PP-G-C-SS-X The meanings of these values are as follows:
YYYY = The four digit year of birth
MM = The two digit month of birth
DD = The two digit date of birth
PP = The province code, a two digit code between 00 and 14 to represent the province in which the individual was born. 00 indicates birth outside the country.
G = Gender as declared, a one-digit number between 1 and 3 to represent male, female, or another classification.
C = Citizenship, a 0 or 1 for non-citizen or citizen. A person is automatically a citizen if born in Pascalia, but non natives can become citizens as well.
SS = A serial number from 00 to 99 that separates people with the same set of circumstances (same birthdate, place, gender, citizenship). The first person with those circumstances will be 00, the second 01, the third 02, and so on.
X = The checksum digit, which is always 7 (see below).
For example, Blaise's ID number is 1623-06-19-01-1-1-01-7. This means he was born on June 19, 1623 in province 01. He identifies as male and is a citizen of Pascalia. At least one other male was born on that date in province 01, since his serial number is not 00. All seven of his identifying characteristics are valid numbers.
A bogus ID number would be one such as 1910-07-42-21-1-2-78-7. The date of birth (42) is out of range, as well as the province code (21) and the citizenship (2). A computer could recognize this is invalid because the number of valid parts (4) is not equal to the checksum digit (7) at the end of the code.
Your program needs to read in a Pascalia ID, separate it into substrings of an array, convert them to integers, and then output a message in the following format if the number is valid:
If invalid, nothing should be output.
SCORING (1 point for valid attempt of program, then 1 point for each correct without an override):
------------------------------------------------------------------------------------------------------------------------
INPUT: 2017-10-18-12-2-1-03-7
OUTPUT: Female citizen born in province 12 on 10-18-2017 with at least 3 similar IDs.
------------------------------------------------------------------------------------------------------------------------
INPUT: 2015-01-01-00-1-0-00-7
OUTPUT: Male non-citizen born in province 0 on 1-1-2015 with at least 0 similar IDs.
------------------------------------------------------------------------------------------------------------------------
INPUT: 201-20-20-99-5-5-1000-3
OUTPUT: Invalid
------------------------------------------------------------------------------------------------------------------------
INPUT: 1999-11-11-02-2-0-04-7
OUTPUT: Invalid
Note: Because of birth inside Pascalia, this person is a citizen!
The Republic of Pascalia has decided to implement a national ID number for its citizens. The format of this ID number is as follows: YYYY-MM-DD-PP-G-C-SS-X The meanings of these values are as follows:
YYYY = The four digit year of birth
MM = The two digit month of birth
DD = The two digit date of birth
PP = The province code, a two digit code between 00 and 14 to represent the province in which the individual was born. 00 indicates birth outside the country.
G = Gender as declared, a one-digit number between 1 and 3 to represent male, female, or another classification.
C = Citizenship, a 0 or 1 for non-citizen or citizen. A person is automatically a citizen if born in Pascalia, but non natives can become citizens as well.
SS = A serial number from 00 to 99 that separates people with the same set of circumstances (same birthdate, place, gender, citizenship). The first person with those circumstances will be 00, the second 01, the third 02, and so on.
X = The checksum digit, which is always 7 (see below).
For example, Blaise's ID number is 1623-06-19-01-1-1-01-7. This means he was born on June 19, 1623 in province 01. He identifies as male and is a citizen of Pascalia. At least one other male was born on that date in province 01, since his serial number is not 00. All seven of his identifying characteristics are valid numbers.
A bogus ID number would be one such as 1910-07-42-21-1-2-78-7. The date of birth (42) is out of range, as well as the province code (21) and the citizenship (2). A computer could recognize this is invalid because the number of valid parts (4) is not equal to the checksum digit (7) at the end of the code.
Your program needs to read in a Pascalia ID, separate it into substrings of an array, convert them to integers, and then output a message in the following format if the number is valid:
- Gender citizenship born in province provincenum on MM-DD-YYYY with at least number similar IDs
- Note that leading zeroes do not need to be in the output, so an input of 01 can be output as 1.
If invalid, nothing should be output.
SCORING (1 point for valid attempt of program, then 1 point for each correct without an override):
------------------------------------------------------------------------------------------------------------------------
INPUT: 2017-10-18-12-2-1-03-7
OUTPUT: Female citizen born in province 12 on 10-18-2017 with at least 3 similar IDs.
------------------------------------------------------------------------------------------------------------------------
INPUT: 2015-01-01-00-1-0-00-7
OUTPUT: Male non-citizen born in province 0 on 1-1-2015 with at least 0 similar IDs.
------------------------------------------------------------------------------------------------------------------------
INPUT: 201-20-20-99-5-5-1000-3
OUTPUT: Invalid
------------------------------------------------------------------------------------------------------------------------
INPUT: 1999-11-11-02-2-0-04-7
OUTPUT: Invalid
Note: Because of birth inside Pascalia, this person is a citizen!