CS 010 - Introduction to Computer Science I
Assignment 5:

DUE: Monday November 15th before 5:00pm


Collaboration Policy

Collaboration is strongly ENCOURAGED. You will be working in teams, but programs must represent YOUR OWN original work. Teams should work on the algorithm together and help debug/test each others code. However, copying code from ANY source (any book, current or past students, past solutions, the web, etc.) is STRICTLY FORBIDDEN. Code between teamates will be similar, but you are not allowed to just copy a teamate's solution.


Code that is turned in, must be contained in a .cpp file named main.cpp. Files of any other format will not be graded (e.g. main.doc, main.txt, etc…).

You must turn your work in from a lab computer on campus.

Turn in online to as5-(group letter) folder. If you turn your assignment in to the wrong folder, your assignment may not be graded. If it is graded, you will lose 2 pts (out of 10).

Remember to include the following header information at the top of your program;

// Course: CS 10
//
// Lecture Section: ... 001 or 002
// Lab Section: ... 021, 022, etc)
//
// Assignment #: ... assignment 2, 3, etc.
//
// Last Name: Enter your LAST (family) name here (eg, Doe)
// First Name: Enter your FIRST (given) name here (eg, John)
//
// ID Number: Enter your ID number here (eg, 860-00-0000)
// lab login id: Enter your cs10 login here (eg, jdoe)
//
// Email address: Enter your UCR email address here (eg, jdoe@cs.ucr.edu)
//
// Group: Enter your group here (eg, D4)
// Teammates: List the names of the teammates you worked with
// Meeting Time: Specify the next time your team plans to meet
//
// =======================================================================


Problem Definition:

    For this assignment you will write 3 functions that return values, and add 9 lines of code that are missing from ccc_win_main().  The values returned will be used in a control algorithm.  The control algorithm simulates a body falling under the force of gravity, and with the capability to produce upward "thrust" through a rocket engine.  The code needed to impliment the control algorithm--including animation--has been partially written, and is contained in the file below.
    You will need to write three function definitions;  a function that returns a new position based on the current position, velocity, acceleration, and time,  a function that returns a new velocity based on the current velocity, acceleration, and time, and a function that returns an acceleration value based on the user's input.  To calculate the position you will use the equation given in assignment one, to calculate the velocity you will use the equation: v_final = v_initial + acceleration * t.  The value returned by the acceleration function will depend on the user's selection for the thrust; 0 for (l)ow, 1 for (h)igh, and -1 for (n)one.
    In the body of the ccc_win_main function, you will need to add code to the while loop.  A numbered comment indicates where the line of code needs to be added.  For each numbered comment in the loop, add only ONE line of code.  All the variables you will need have been declared in ccc_win_main before the while loop, and you can ONLY use these variables in the lines of code that you add.
    IMPORTANT NOTE:  The constant "FRAME_RATE"  controls how often the time "t" variable for the circle is increamented, thus how often the circle moves on the screen.  On slower computers this should be set to a smaller value than given, but on faster computers this should be set to a bigger value.  You might have to do some *tweaking* to this value to get your animation to look smooth.  Also, the program does not naturally terminate, so you must type <control-c> from the terminal to close the graphics window.

Starting Code
main.cpp

Example Program Download
main


Rubric: (10 pts total)

1 pt: Correct header for position function AND returns correct value
1 pt: Correct
header for velocity function AND returns correct value
1 pt: Correct header for acceleration function AND returns correct value
2 pts: Added correct lines of code for comments 2, 3, and 4
2 pts: Added correct lines of code for other comments
0.5 pt: Only added one line of code for each numbered comment
0.5 pt: No variables/constants were added to the program (used variables that were already declared in ccc_win_main)
2 pts: Style
- Good variable names
- Proper indentation and spacing
- Good comments
- No line wraps
- No magic numbers