CIT020 Index > C++ Assignment: Types, Variables, and Standard I/O

C++ Assignment: Types, Variables, and Standard I/O

Read everything before doing anything.

Part One

Do Exercise 3 on page 34:

Write a program that gets three game scores from the user and displays the average score.

Save the source file in the form lastname_firstname_average.cpp. Thus, if your name is Fred Bloggs, you would name the file bloggs_fred_average.cpp. Do not put blanks in your file names, and make sure you use all lowercase. If your file is not named properly, it will not be graded.

When You Finish Part One

Attach the .cpp file to an email and send it to the instructor. You must put the words CIT020 C++ Assignment Vars Part 1 in the subject line of your email, or it will not be graded.

Part Two

In some games, characters run through a maze and jump to reach objects that are worth points. The height to which a character can jump is based upon the initial speed and a “power factor” that increases that speed.

Your program will ask the user for a character’s speed in dots per second and a power factor in the range 1-2. It will calculate the maximum height of the jump and display it.

You will save the program in a file whose name is in the form lastname_firstname_jump.cpp. Thus, if your name is Suze Jerusalem, your file should be named jerusalem_suze_jump.cpp. If your file is not named properly, it will not be graded.

Here is information to help you write your program.

Input Variables
Initial Speed
Power Factor
Gravity Factor (constant of 60)
Output Variable
Height
Processing Variable
Jump Speed
Processing
  1. Prompt the user for the Initial Speed.
  2. Read the Initial Speed from the keyboard.
  3. Prompt the user for the Power Factor.
  4. Read the Power Factor from the keyboard.
  5. Calculate the Jump Speed as Initial Speed times Power Factor.
  6. Calculate Height as Jump Speed times Jump Speed divided by Gravity Factor
  7. Display Height, labelled properly.

All of your variables should be double (even the height). Here is an example of what running the program might look like. User input is bold and red. Your output does not have to look exactly like this, but it must convey the same information.

Enter initial speed in dots/second: 60
Enter power factor (1 to 2): 1.3
Your jump height is 101.4 dots.

When You Finish Part Two

Attach the .cpp file to an email and send it to the instructor. You must put the words CIT020 C++ Assignment Vars Part 2 in the subject line of your email, or it will not be graded.