Advertisement
Guest User

Untitled

a guest
Feb 17th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main ()
  5. {
  6. double temp1, temp2, velocity;
  7. //Only changed these two lines
  8. bool programRun = true;
  9. //Program will continously run indefinitely. Simply have an option like "Enter start temperature in degrees Celsius or type 'x' or 'X' to end the program"
  10. while(programRun == true)
  11. {
  12. cout << "Enter start temperature in degrees Celsius =>\n";
  13. cin >> temp1;
  14. cout << "Enter end temperature in degrees Celsius =>\n";
  15. cin >> temp2;
  16.  
  17. while ( temp1 > temp2 )
  18. {
  19. cout << "Start temperature must be less than end temperature. Please try again.";
  20. cout << "Enter start temperature in degrees Celsius =>\n";
  21. cin >> temp1;
  22. cout << "Enter end temperature in degrees Celsius =>\n";
  23. cin >> temp2;
  24. }
  25.  
  26. //Run program if end temp is smaller than start temp.
  27. while ( temp1 < temp2 )
  28. {
  29. velocity=(.61*temp1)+331.3;
  30. cout << "At "<<temp1<<" degrees Celsius the veloicty of sound is ";
  31.  
  32. cout.setf(ios::fixed);
  33. cout.setf(ios::showpoint);
  34. cout.precision(1);
  35. cout << velocity<< " m/s\n";
  36. temp1++;
  37. }
  38.  
  39. }
  40.  
  41.  
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement