CSCI 1300
Introduction to Computer Science - Spring 2003
Homework I

This homework must be submitted online by 9am on Wednesday, January 22. You must also bring a printed copy of your investment program to turn in to your TA at recitation on January 22.

Preparation

Make sure you've gone through the week's preparation list.

Register with Dora for CSCI 1300

Visit the page www.cs.colorado.edu/~main/dora and create a dora login for yourself. Use the same login name that you were given for all CU computers, but choose a different password. After creating your login, go back to the dora page, login, and add yourself to the CSCI 1300 roster.

Programming Style

Beginning with the second homework, you'll need to follow a particular programming style that will be discussed in class. For this homework, you can use your own style, provided that you include a comment at the top of the program with:

IA. Submit a Photo

Find someone with a digital camera or scanner and get a digital picture of yourself in gif or jpg format (or use an old picture). Send the picture to at least one other person in your recitation group, and submit the picture to Dora for Homework IA.

IB. A Tiny Program to Print the Number 42

This part of the assignment is open: You may consult with other students and look at their work if it will help you understand. Or you may do your work on your own and show it to someone else for feedback before submitting. You may even work in groups and trade solutions back and forth. Please acknowledge those that you work with by putting a comment at the top of the program.

The purpose Assignment 1B is to make sure that you know how to submit programs through the Dora Assignment Submission Process, and then check your feedback from her.

Write a short program called print42.cxx. The program writes the number 42 followed by exactly one endl (with all output sent to cout). The program does not have any input. There is no other output. Some notes are given below:

After you check that the program compiles and runs correctly, go to the following page to submit your program to Dora:

www.cs.colorado.edu/~main/dora
Remember, the purpose is merely to make sure that you can use the dora system. Keep in mind that the dora system may get bogged down or be unavailable if you wait until the last minute to submit your work. I'd suggest that you submit at least 24 hours ahead of time to avoid late penalties from unexpected problems (that aren't always your fault!)

After you submit to Dora, wait a few minutes and then check her feedback. You do this by clicking the button to submit assignments. All assignments are listed there with their current status. If she rejected the program for any reason, you may fix the problem and resubmit.

IC. Body Mass Index

This part of the homework is also open, so that you may work with others (as described in IB).

The purpose of Assignment 1B is to make sure that you know how to write a small program that reads some information, does a calculation, and prints results that are based on that calculation.

Write a short program called bmi.cxx to calculate a person's "body mass index" as described below.

The Input: The program asks the user for these pieces of information:

  1. Your weight in pounds
  2. Your height in feet and inches (two separate input numbers)
The program must prompt for these items and read them in the order listed above. You may not change the input specification (if you do, then Dora will get confused). In order to avoid problems with division by integers, I would suggest that you declare all three variables to be double numbers.

The Output: The program prints messages with this information:

  1. The person's weight in kilograms. (Information for the calculation: There are 0.45359237 kg per pound.)
  2. The person's height in centimeters. (Information for the calculation: There are 2.54 cm per inch.)
  3. The person's metric body mass index. This is calculated as:

    10,000 * (weight in kg) / (height in cm)²

    Note:There is a "division" symbol in the middle of the above formula and a "square" symbol at the end.

  4. A message about the person's height. The message must be one of these: In order to print the message in the last step, you'll use if-statements. The only numbers in the output should be the three numbers listed above, and these numbers must be in the order: weight, height, BMI. Otherwise, you'll confuse Dora and she won't give you any points at all.

Check that the program compiles and runs correctly. Submit the program to Dora and check the results a few minutes later. If Dora did not give you credit, then you can fix any errors and resubmit.

ID. Investment Comparison

[CAUTION!] This part of the homework is a take-home exam. This means that you may not discuss or consult with anyone other than the course instructors. Please put one of this messages in the comment at the top of your program:

On my honor as a University of Colorado at Boulder student, I have neither given nor received unauthorized help with this assignment. I understand that any violation of this policy will result in a grade of F for the entire course.
Or (if you could not complete the assignment):
I could not complete the assignment without help and am submitted it for no credit. Please contact me about getting help from the instructors for the next assignment.

If you end up not submitting one or two of the take-home exams, it will lower your grade, but just a little bit. The points for the take-home parts are relatively small. But we need to know that you are doing those parts by yourself so that we can do accurate evaluations of where the class is (as a whole) and where you are individually. Doing these evaluations allows us to determine whether most students correctly understood what was learned in the open assignments, and it allows us to provide customized help. Anyway, on to the assignment...

You have a choice of two possible investment plans: In both plans, you will have a fixed number of dollars to invest (called the "amount") for a fixed time period.

In plan A:

In plan B:

Write a program that reads all the necessary information from the user, computes the value of the investment at the end of the period (taking taxes into account), and prints an additional message indicating whether one plan is better than the other (and if so, which one is better).

Note: The results of your program may consfuse you. For example, you might provide input data that *should* end up with the two plans being equal...but they aren't. This is caused by an inaccuratcy in double number arithmetic, which we will discuss next week.

  • In addition to the comment at the top of the program, make sure that you have a clear indication of where these parts of the program occur: The variable declarations, the input, the calculations, and the output. Try to keep the length of your main program under 35 lines of code (not counting the variable declarations).

    Check that the program compiles and runs correctly, and submit the program to Dora. Dora will not grade this one (except to record one point for submission), but your TA will provide some feedback and grading.

    Deadlines

    Work should be submitted to Dora by 9am on Wednesday, Jan 22. And you should bring a printout of the investment comparison to your recitation to turn in to the TA.

    Students who do not give a printout to the TA during recitation will have a 10% penalty. Students who submit work after 9am on Wednesday will have an additional penalty: 10% for late Wednesday submission; 30% for Thursday submission; 50% for Friday submission; 70% for weekend submission; 90% for Monday submission. No submissions after Monday.