CS
010 - Introduction to Computer Science I
Assignment 1:
DUE: Tue, June 29 before 11:00pm
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 using electronic turnin as in lab1, from a lab computer on campus, TURNING IN FROM HOME WILL NOT WORK!
Turn in online to as1 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;
// last
name, first name
// last 4 digits of SID
// UCR email address
// user name (log in name)
For
this assignment you will write a program that asks the user for
information about the initial (x,y) position, and (x,y) velocity of an
object. Given this information, the program will then print out the
(x,y) position of the object at 0, 1, 2, 3, and 4
seconds. You will use the following equation to compute the position
over time:
x_pos = x_init +
(x_vel * t) + 0.5 * (x_acc * t * t)
where "x_init" is the
initial x position, "x_vel" is the initial velocity in the x direction,
"x_acc" is the acceleration in the x direction, "t" is the time in
seconds, and "x_pos" is the x position after "t" seconds. A similiar
equation would be used to compute the y position over time. You can
assume that the object is under freefall in earth's atmospere, so
acceleration in the y direction is a constant -9.81, and acceleration
in the x direction is a constant 0.0. In your program these
accelerations should be declared as constant doubles, and "t" should be
a variable int.
Example program run:
What is the initial x
position? 34
What is the initial y position? 100
What is the initial x
velocity? 1.3
What is the initial y velocity? 0
Position after 0
second(s) is (34, 100)
Position after 1 second(s) is (35.3, 95.095)
Position after 2 second(s) is (36.6, 80.38)
Position after 3 second(s) is (37.9, 55.855)
Position after 4 second(s) is (39.2, 21.52)
2 pts: Correctly declare constants and variables
2 pts: Gets input
2 pts: Calculations use variables for time, position and velocity, but constants for acceleration
2 pts: Correct output
1 pt: Header info (provide correct info specified above)
0.5 pt: Compiles without errors
0.5 pts: Style
- Good variable names
- Proper indentation
- Good comments
- No line wraps
Bonus +1 point
Read ahead, and figure out how to use a "while loop" to increament the
time variable.