CSCI 1300 - Programming Assignment 1
Using the G++ Compiler


  • Start: Immediately after your recitation on week of Jan 24.
  • Due: Wednesday, Feb 2.
  • For hadware problems: late work accepted without penalty on Thursday, Feb 3.
  • Late work accepted with penalty: through Saturday, Feb 5
  • No work accepted after Feb 5.

    Homework Policy [CAUTION!]
    Please read before submitting:
    All work that you submit in this class must be entirely your own. In particular:

    Breaking these rules will result in an F for the entire course.

    Assignment 1-1:

    The purpose of this first part is to make sure that you know how to submit programs through the Dora Assignment Submission Process. Write a short program called print42.cxx. The program writes the number 42 followed by a single endl (with all output sent to cout).

    Check that the program compiles and runs correctly. Then go to the following page to register your account with Dora:

    After you have registered, go to the following page and add your CSCI 1300 section to your Dora account. Make sure that you add the section that corresponds to your instructor (Gillett, Lewis, or Main):

    Finally, return to the dora page and submit the print 42 program. 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. If she rejected the program for any reason, you may fix the problem and resubmit.

    Assignment 1-2:

    Part 2 of this assignment is to write and run a program that meets the following specification. Make sure that the style of your programs (indentation and so forth) looks like the examples in the book. You should also read the programmer's style guide in your lab book (also at Include a comment at the top of each program with the same items as your Assignment 1-1 program.

    The specification: A university research lab has concluded that an artificial sweetener commonly used in diet soda pop will cause death in laboratory mice. A friend of yours is desperate to lose weight but cannot give up soda pop. Your friend wants to know how much diet soda pop it is possible to drink without dying as a result. Write a program to supply the answer. The input to the program is the amount of artificial sweetener needed to kill a mouse, the weight of the poor mouse, and the weight of the dieter. To ensure the safety of your friend, be sure the program requests the weight at which the dieter will stop dieting, rather than the dieter's current weight. Assume that diet soda contains 1/10th of one percent artificial sweetener. Use a const declaration at the top of the program to give a name to this fraction (which you might want to express as a double number 0.001). Your program should allow the calculation to be repeated as often as the user wishes (by having a loop in the main program, which continues until the user indicates that he or she is ready to stop).

    The program has three inputs (all double numbers):

    This is probably unrealistic, but assume that the amount of sweetener to kill the dieter is proportional to his weight. For example, if the dieter is 500 times the weight of the mouse, then assume that the dieter would need 500 times as much sweetener to kill him.

    To calculate the amount of soda pop needed to kill the poor dieter, divide the amount of sweetener by the fraction of sweetener in the soda. For example, if you determine that it takes 42 ounces of sweetener to kill the dieter, and the fraction is 0.001, then it would take 42/0.001 ounces of soda pop to kill him (which is 42000 ounces).

    To repeat the calculations until the user says to stop, use the following format.

       char another;
          ...input, calculations and output...
          cout << "Another calculations? [Y or N]" << endl;
          cin >> another;
       }  while ((another != 'N') && (another != 'n'));