Difference between revisions of "CSC111 Homework 4 2015"
(→Problem #4) |
(→Problem #4) |
||
Line 57: | Line 57: | ||
=Problem #4= | =Problem #4= | ||
<br /> | <br /> | ||
− | Write a program that prompts the user for her first and last name, and outputs a triangle made with her name, padded | + | 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. |
<br /> | <br /> | ||
:;Example | :;Example | ||
Line 63: | Line 63: | ||
First name? Maria | First name? Maria | ||
Last name? LUCE | Last name? LUCE | ||
− | + | ........M | |
− | + | .......Ma | |
− | + | ......Mar | |
− | + | .....Mari | |
− | + | ....Maria | |
− | + | ...MariaL | |
− | + | ..MariaLU | |
+ | .MariaLUC | ||
+ | MariaLUCE | ||
MariaLUC | MariaLUC | ||
MariaLUCE | MariaLUCE | ||
</source> | </source> | ||
<br /> | <br /> |
Revision as of 15:52, 15 February 2015
--D. Thiebaut (talk) 15:23, 15 February 2015 (EST)
Contents
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 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 MariaLUC MariaLUCE