Assignment1 Winter
Assignment1 Winter
Submission instructions:
- Create a cpp file for each question
- Create a pdf file containing the screenshot of all programs and their results. Save the pdf file and
all .cpp files in a folder
- Name the file as your lastname_student id
- Compress the files using zip or other tools and name the file as your lastname_student id
- Submit the zip file on Moodle
- Do not submit executable files
- All submissions must be done through Moodle
Your Information:
First Name:
Last Name:
Student ID:
Grade:
Expectations of originality:
Paste the signed form here or submit it as a separate file with this assignment:
Questions:
1. (15 marks) Write a program that prompts the user to enter three integers as shown and prints the
sum, the minimum, the maximum, and the average of these numbers.
*****************************************
*****************************************
2. (20 marks) Write a program that converts a 4-bit binary number to its hexadecimal equivalent. The input
must be in the range 0000 to 1111 otherwise the output will be "Invalid binary number" but the system
may ignore leading zeros. The output should look like this:
1/2
COEN 243-A1
3. (20 marks) Write a program that prompts the user to enter the correct username and password or
username and security code to log into the account. Assume the password and security code are 4 digits
long. The output should either be a successful login or invalid login, try again. For example, if this
account belongs to Tom and his password and security code are 1234 and 4321 respectively, you might
get the following results:
4. (25 marks) Write a program that checks the validity of user identifiers. Assume your identifier is 3
entries long. Ignore all keywords. As shown in the following:
5. (20 marks) Write a code in C++ to derive the permanent code from your age and date of birth. The
Permanent Code System (PCS) should work as follows:
Conditions:
- Follow the format shown in all relevant figures.
- The permanent code consists of two characters and six numbers, e.g. FV901203.
- The first two numbers represent the last two digits of your year of birth (e.g. If you were born in 1990,
use 90 in your permanent code.)
- The second two numbers represent your month of birth (e.g. if you were born in Dec use 12 in
permanent code).
- The third two numbers represent your day of birth (For example, if you were born on the 3rd of the
month, use 03 in the permanent code).
- After calculating the age, convert the number of years to a capital letter. Assuming that 1 is 'A', 2 is 'B',
and 26 is 'Z'. In case your age is above 26 warp around starting from 1 (e.g. your age is 32 becomes 6 and
it is 'F'. This character is the first letter in the permanent code.
2/2
COEN 243-A1
- Similarly, you can calculate the second letter but using the days of your age.
- You are not allowed to use any header files except <iostream>.
Limitations:
- Assume all months are 30 days.
- Assume your age doesn’t exceed 99 years.
- Assume your age doesn’t include 0 years or 0 days.
- Assume that the user will enter the correct information so that the code does not check the
correctness of the data.
Notes:
- Sometimes surfing the internet to find a ready-made solution wastes your time.
- I use these questions to mine your beautiful minds and I'm sure I'll find the shiniest ideas.
3/2