Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- float calculate(float &num1, float num2)
- {
- float miles = num1;
- float hours = num2;
- float milesPerHour;
- milesPerHour = miles / hours;
- return(milesPerHour);
- }
- int main()
- {
- float miles;
- float hours;
- float mph;
- cout << "Please input the miles traveled: " << endl;
- cin >> miles;
- cout << "\nPlease input the hours traveled: " << endl;
- cin >> hours;
- cout << endl;
- mph = calculate(miles, hours);
- cout << fixed << setprecision(2) << "Your speed is " << mph << " miles per hour." << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement