Optional Homework Assignment #6
CS
161: Introduction to Computer Science 1
Submit your Solutions
to D2L’s Dropbox
*** Our
objective with homework #6 is to prepare for the final exam and for CS162! ***
Part
1: Short answer questions:
For the following questions, write code fragments in C++
that answer the following questions.
Write the answers for each of these in
C++.
1.
Show the
variable definitions necessary for holding your name, address, email address,
and phone number
2.
Prompt the
user for your each of the items listed in question #1 and read them in
3.
Display
just your last name
4.
Capitalize
just the first letter of your last name
5.
Now, upper
case ALL letters in your entire name
6.
Show how
you could compare the name to see if it is KARLA FANT
7.
Write ONE
if statement to find out if the first letter of the name is between A and Z
8.
Write one
if statement to find out if the 4th character of the phone number is
a hyphen, eg., “503-725-5394”
9.
Find out if
the last 3 characters of the email address is .edu
10. Show an example where it would be useful to use cin.ignore(100,’\n’);
11. Write a funciton that will count all of the hyphens (-) in the
phone number. Pass the phone number as an argument and return the count. Use a for loop.
12. Rewrite your solution to #11 using a while loop
13. Write a function that reads in someone’s name and salary and
supply this information back to the calling routine through the argument list
(hint: pass by reference)
14. Write a do-while loop that calls the function in #13 until
the person using the software is satisfied with the information that they
entered.
Part 2: Problem Solving
Background: Rarely in the real world will your boss come to you with an
exact specification and algorithm for a program. It is more typical that they
will come with a problem that needs to get solved. Computer Scientists evaluate
the problems, learn how to problem solve, run their planned solutions through
the people involved, create more detailed plans (requirements, specifications,
algorithms, overall design ideas) all before they sit down to program.
Programming is just one small piece of the puzzle. But, as we have learned this
term it is an important piece and one that sometimes can be time consuming.
This is especially the case if we haven’t properly thought out the problem and
considered all of the avenues.
Therefore,
think about PSU’s registration system. If we were to design a system like this,
what would we need to think about? Write
three questions that you would need to ask PSU in order to begin designing
software for a registration system.