Due: Friday, Sept. 11, 2015 at noon 100 pts
For this assignment, you will submit a single C++ compilable file containing a program written in C++. Remember, to electronically submit a file to for this course, first change to the directory in which the file resides and then type in, at the UNIX prompt, the command:
Background: This semester, you will be working as a software developer for a client who is an established, well-connected and talented intellectual giant. In the programming assignments over the course of the next few months, Homer Simpson (pictured at right) will require your programming acumen and expertise, outlining what programs will make his life easier - something he dearly needs. Yes....he is your boss. Disturbing, isn't it? Imagine him in politics! Homer now needs your help to write a program to generate passwords for a new online "Brainwave Generation Exercise" business he wants to start. Each client would enter personal information that is to be used by the program to produce a password. The password must be 'strong' so he has devised the most bestest solidest-ish formulation that will output characters (letters) for the password. The formula is used 4 times for a 4-letter password.
Be sure that only the file you want to submit is in that directory - make a directory for every assignment! Remember that the submit system will deliver every .cpp file in the current directory to me, so you should only have the file for hw 2 in that directory. Name your file a meaningful name and give it a .cpp extension since you will be compiling it. Also, make sure that you compile and run your program using the GNU (g++) compiler before submitting to make sure that it will work for the submit script.
cssubmit 1570 section_letter assignment_number
K = is the product of the aforementioned constants
32 is yet another formula constant (that is the average IQ of people who eat glue regularly)
65 is another formula constant (representing daily doughnut consumption for Homer)
where 26 is a formula constant (that happens to be Homer's IQ)
letter = [ (brain wt / age) * K ] mod 26 + 65 + 32(but only if they eat glue),
Specifications: Your program is to prompt the user for input of their age (an integer), the approximate weight of their brain1 in pounds (an integer), and whether or not they regularly eat glue. (Some clients need extra help. See picture at right.) For this last input, your prompt should request a 0 (for no) and 1 (for yes), and the value be assigned to a boolean variable. These inputs are to be used in this formula:
Now, for the sake of security, after each use of the formula, the value of K must change. Thus, subsequent letter generations by this formula must use the previous value of K incremented by 100.
Note: The computation on the right hand side of this formula will produce a number. However, it is implied that the left hand side of the formula is a character (a letter). Assigning a number to a letter would seem an odd thing to do. But this allowed by C++. However, it is important that you write your code in such a way as to make it clear it is your intention to do so. Think about converting from one type to another. The number so generated on the right is to be the ASCII value of the character on the left.
Note also: You are not allowed to use conditional statements (if or if-else) in the program. Think carefully how to use the information you have input from the user, how it is stored, how boolean variables are represented.
Note also also: It is up to you how you want to name your variables and constants. Don't think that you should copy names that your employer/teacher/mentor(see picture above) use to describe a problem. YOU are writing the code.
Special Note: By the time you read this, you will have had the hierarchy of types, automatic conversions, and casting explained to you. And when you assign the value of a 'higher' type variable (say, a float) to a 'lower' type variable (say a short), information is lost - the decimal part is discarded. Using the compiler call fg++ allows that behavior without any compiler error or warning. However, to insure that the reader of the code (and the compiler) understands that this is indeed what you want to do, you should explicitly cast the value. We cannot easily change fg++, but we can (and have!) changed how cssubmit compiles your code. It will throw a warning if you do not explicitly cast when assigning in such a manner. To get the same behavior from the compiler when you are developing your program, use the compiler call
fg++ -Wconversions <your source code>
and warnings will be issued like they will be when you use cssubmit. A compiler warning is as bad as a compiler error! Fix them; if you get a warning, fix your code so it doesn't give you a warning. Also, you can get the same result by compiling with clang++.
Since posting this, we have found that the above flag will produce warnings for other operations (such as multiplying a float and an int) that we did not anticipate. So, don't use the above flag. We have removed it from the cssubmit call to the compiler. Using clang++ should give you the behavior we intended. But be sure to use static_casts properly to explicitly tell the compiler and anyone who reads your code that you intend to make such an assignment.
Your program should be "user friendly" in that it should have an opening statement or greeting, user friendly and understandable prompts, and clear and concise outputs and sign-off. Here's a good example of bad output:
enter stuff: 52 6 0
5
Notice that there are NO prompts to speak of, and the output is completely unexplained. This is horrible output. Something like the following is much much better:
Welcome to the PASSWORD GENERATOR
Please enter the following information:
what is your age: 77
how much does your brain weigh: 6
do you eat glue regularly: 1
Your password is: cjrz
Have a nice day and don't forget that password!
When you submit: When you submit this, and all subsequent programs for this class, cssubmit will compile and run (assuming it compiles) your program during the submission process. Thus, when you submit, you will have to enter inputs as a user of the program. Now, in order to make the output uniform for the grader and to keep them sane, ALL OF YOU will enter the same information. For this assignment, it is:
age: 33
brain wt: 5
glue eater: 1
As always, if you have any questions about this assignment, be sure to ask your (lecture) instructor.
1There are options for obtaining this value
remove your brain and take it to the post office for an accurate weighing
make a bowl of oatmeal and weigh it
just lie - your mother will forgive you...this time.