Difference between revisions of "CSC111 Homework 4 2015"
(→Problem #7) |
|||
Line 5: | Line 5: | ||
</bluebox> | </bluebox> | ||
<br /> | <br /> | ||
+ | __TOC__ | ||
+ | <br /> | ||
+ | <tanbox> | ||
+ | Make sure you use a main() function in all your programs. | ||
+ | </tanbox> | ||
<br /> | <br /> | ||
=Problem #1= | =Problem #1= |
Revision as of 10:11, 17 February 2015
--D. Thiebaut (talk) 15:23, 15 February 2015 (EST)
Make sure you go through the Preparation Page for Homework 4 first, before attempting these programs!
Make sure you use a main() function in all your programs.
Problem #1
Write a program that prompts the user for her first and last name, and outputs a computer account made of the first initial of her first name, plus her last name, all in lowercase.
- Example
First name? Allie Last name? BABA Your computer account name is: ababa
- Submit your program to HW 4 PB 1 on Moodle.
Problem #2
Write a program that prompts the user for her first and last name, and outputs a computer account made of the first initial of her first name, plus her last name, all in lowercase. But now we want the computer account to be exactly 8 characters long. If the user names are too short, your program will pad it with the character 'z'.
- Example
First name? Allie Last name? BABA Your computer account name is: ababazzz
First name? Al Last name? Gus Your computer account name is:aguszzzz
First name? Alma Last name? Verylongname Your computer account name is: averylon
- Submit your program to HW 4 PB 2 on Moodle.
Problem #3
Write a program that prompts the user for her first and last name, and outputs a computer account made of the first initial of her first name, plus her last name, all in lowercase. We want the computer account to be exactly 8 characters long, but this time it is padded with the current year (2015 for us).
- Example
First name? Allie Last name? BABA Your computer account name is: ababa201
First name? Al Last name? Gus Your computer account name is: agus2015
First name? Alma Last name? Verylongname Your computer account name is: averylon
- Submit your program to HW 4 PB 3 on Moodle.
Problem #4
Write a program that prompts the user for her first and last name, and outputs a triangle made with her name, padded with dots in front of it, as illustrated below. There is no limit on the length of the first and last names.
- Example
First name? Maria Last name? LUCE ........M .......Ma ......Mar .....Mari ....Maria ...MariaL ..MariaLU .MariaLUC MariaLUCE
- Submit your program to HW 4 PB 4 on Moodle.
Problem #5
Write a program that prompts the user to enter a date in the form mmddyyyy, and displays it back as dd month yyyy, where month is the first 3 letters of the name of the month, in English.
Your program must use the list of months defined as follows:
monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
- Example
Enter date: 02042015 4 Feb 2015
- Submit your program to HW 4 PB 5 on Moodle.
Problem #6
Write a program that prompts the user to enter a date in the form mmddyyyy, and displays it back as dd month yyyy, where month is the first 3 letters of the name of the month, in English.
Your program must use the string defined as follows, and cannot use the list you used in Problem 5!
monthNames = "JanFebMarAprMayJunJulAugSepOctNovDec"
- Example
Enter date: 02142015 2 Feb 2015
- Submit your program to HW 4 PB 6 on Moodle.
Problem #7
Write a program that asks the user for several pieces of information about some famous person, and outputs the information in a nicely formatted box, where the length of the bar of '=' signs before and before the information is the same as the length of the accomplishment information.
- Example
Please enter first name: Sophia Please enter last name: SMITH Please enter date of birth (yyyymmdd): 17960827 Please enter date of death( yyyymmdd): 18700612 Please enter accomplishment: Funded Smith College, the largest member of the seven sisters. ============================================================== Sophia Smith (August 27, 1796 -- June 12, 1870) Funded smith college, the largest member of the seven sisters. ==============================================================
- Note that the name is formatted correctly, even if the user enters all uppercase or lowercase letters for the name.
- Submit your program to HW 4 PB 7 on Moodle.
- Note
- The bar of '=' signs will not show up correctly on Moodle, because of it uses a proportional font. However, Idle will display the output correctly, so make sure you debug in Idle and use Moodle just for submission. Resist the urge to modify your program in Moodle. Idle is a much friendlier place to edit programs.