// FILE: voyage1.cxx // Written by Michael Main (main@colorado.edu) // This is a first example of a C++ program. The program // computes how long a trip takes. The primary purpose is // to llustrate input, output and assignments in C++. #include // Provides cin and cout using namespace std; int main( ) { double distance; // The distance for a trip, in miles. double averageSpeed; // Average trip speed, in miles/hour. double time; // The time for the trip, in hours. // Read the input. cout << "Please type the trip's distance, in miles: "; cin >> distance; cout << "Your distance is " << distance << " miles." << endl; cout << "Please type your average speed, in miles/hour: "; cin >> averageSpeed; cout << "Your average speed is " << averageSpeed << " miles/hour." << endl; // Computations. time = distance / averageSpeed; // Print the output. cout << "Your trip will take " << time << " hours." << endl; if (time > 2) cout << "You will need a break!" << endl; else cout << "No break is required." << endl; return 0; }