CSCI 240 - Assignment 1 - Spring 2007


Due: Monday, Jan 29, 3 pm.
50 points

Write a program to calculate distance traveled at a user-specified rate and time and also the vertical distance covered given a user-specified slope.The first two sections of the lecture notes and the first two chapters of your text contain information and examples to help with this.

Include a comment section at the top of your C++ source code patterned after the following:

/************************************************************************
CSCI 240 Assignment 1 - Spring 2007

Programmer: your name
Z-ID:       Znnnnnn
Section:    your recitation section number
GA:         your TA's name (see Course Web site)
Date Due:   01/29/07

Purpose:    This program prompts the user to ...
************************************************************************/  

You may recall that there are 5280 feet in a mile.

You will need to:

  1. prompt the user to enter a speed in miles per hour
  2. get and store the speed
  3. prompt the user for the time in seconds
  4. get and store the entered time
  5. prompt the user for the slope (in % so if the user enters 6 this is taken to be 6% or 0.06)
  6. calculate the answers: the total distance traveled in miles and the total vertical distance covered in feet.  You can do this in one or several C++ statements.  You may declare variables to hold partial answers.
  7. display the answers

Use
- #include <iostream>
- using namespace std;
- floating point "double" variables for all numeric values
- cin to get the input values
- do not worry about the number of decimal places displayed
- return 0

A single run should closely resemble the following:

Enter the speed in miles per hour: 3.8
Enter the time in seconds: 600
Enter the slope as a percent (e.g. 6): 6
The total distance traveled: .633333 miles
Vertical distance traveled: 200.639 feet

These results come from:
3.8 mph times 1/6  (600/3600) of an hour = number of  miles
.633 miles times 6% =  number of vertical miles.  That times 5280 =  number of feet

Hand in a printed copy of your source code in the drop box in the CS lab.
Submit an electronic copy.  Instructions are here

If you do not follow these instructions, you will get a score of 0 for the assignment until you do supply all the pieces required.