CSCI 1300
Introduction to Computer Science
Homework 1: The Making of a Star

Due Date

All work must be submitted by 7:50am on Tuesday, Jan 19. Submit the programming work online to http://culearn.colorado.edu. No late work is accepted, so submit what you have before the due date!

Working Alone

You may talk with other students and instructors about the assignments, but you may not look at or copy code written by others. The penalty for violating this code is an F for the entire semester.

The Assignment

Write a program that opens a graphics window and draws seven stars that are roughly in the shape of the Ursa Major (the "Big Dipper"). Each star must be drawn with five distinct lines in the usual pattern for drawing a star.

The sizes of the stars should decrease in this order: Alioth, Dubhe, Alkaid, ζ, β, γ, δ. The Wikipedia article on Ursa Major gives a diagram of the stars' positions with their names.

Program Requirements

Don't leave it until the last moment in case you have trouble figuring out how to submit to CULearn. Remember that no late work is accepted.

  1. The program file must be called dipper.cxx. You must submit this file and no other.

  2. The program must correctly draw the stars as specified.

  3. The program must begin with a comment that includes:
    1. The file name and date it was written.
    2. Your name and e-mail address.
    3. A short description of the purpose of the program.

  4. The program must use one global constants for the window size (which is both the height and width). Call this int constant S.

  5. The sizes and positions of the stars must be based on the window size S. You could do this with 21 more int constants for the stars' sizes and their (x,y) positions. These values must be computed with formulas that involve S. For example, if you want the size of star3 to be 5% of the window size, you could write:
    const double SIZE3 = 0.05*S;
    
    Or you could use the expression 0.05*S directly in your main program. The decision is up to you!

  6. The program must have a function that you write to draw a single star, and this function is called seven times! A prototype and comment for this function must appear at the top of your code. The only parameters for the function are the center coordinates of the star and a number to indicate the size. The implementation of the funtion will call the WinBGIm line function five times. You'll need to use some trigonometry to figure out the (x,y) coordinates of the endpoints of the five lines that it draws. For example, the x-coordinate of the rightmost point is given by this formula:
    center_x + radius*cos(M_PI/10)
    
    This gives a double number, so you'll get a warning from the compiler (because the line function expects an int). Don't worry about that for now. (Later, we'll see how to avoid such warnings!) The constant, M_PI, is the value of π defined in #include <cmath>.

  7. At the end, the program must pause for 20 seconds before closing.

  8. The main program returns EXIT_SUCCESS.

  9. Each function definition (main and the star drawing function) must be preceded by a blank line and a line of dashes and followed by a line of dashes and a blank line.

  10. No line of code may exceed 80 characters.