All pastes #2054436 Raw Edit

Anonymous

public text v1 · immutable
#2054436 ·published 2011-05-06 04:24 UTC
rendered paste body
//Tiffany Sallee
// Lab8
// Calculate distance using speed & time

#include <iostream>
#include <cmath>


using namespace std;

int main()

{
    //declare variables
    int speed;
    int time;
    int distance;
    int hour;
    
    
    // enter speed, do not accept 0 or negatives
    do
    {
        cout << "What is the speed of the vehicle (mph)? ";
        cin >> speed;  
    } while (speed < 1);
    
    
    // enter time, do not accept 0 or negatives
    do
    {
       cout << "How many hours has the vehicle travelled? ";
       cin >> time;
    }while (time < 1);
    
    // distance formula
    distance = speed * hour;
    
    // calculate with repeat for output by hour
    for (hour = 1; hour <= time; hour = hour + 1)

        cout << "After Hour " << hour << " you travelled " << distance << " miles.\n";
        
        
    system("pause");
    return 0;
}