Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. float calculate(float &num1, float num2)
  7. {
  8. float miles = num1;
  9. float hours = num2;
  10. float milesPerHour;
  11.  
  12. milesPerHour = miles / hours;
  13.  
  14. return(milesPerHour);
  15.  
  16. }
  17.  
  18. int main()
  19. {
  20. float miles;
  21. float hours;
  22. float mph;
  23.  
  24. cout << "Please input the miles traveled: " << endl;
  25. cin >> miles;
  26.  
  27. cout << "\nPlease input the hours traveled: " << endl;
  28. cin >> hours;
  29.  
  30. cout << endl;
  31.  
  32. mph = calculate(miles, hours);
  33.  
  34. cout << fixed << setprecision(2) << "Your speed is " << mph << " miles per hour." << endl;
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement