Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main ()
- {
- double temp1, temp2, velocity;
- //Only changed these two lines
- bool programRun = true;
- //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"
- while(programRun == true)
- {
- cout << "Enter start temperature in degrees Celsius =>\n";
- cin >> temp1;
- cout << "Enter end temperature in degrees Celsius =>\n";
- cin >> temp2;
- while ( temp1 > temp2 )
- {
- cout << "Start temperature must be less than end temperature. Please try again.";
- cout << "Enter start temperature in degrees Celsius =>\n";
- cin >> temp1;
- cout << "Enter end temperature in degrees Celsius =>\n";
- cin >> temp2;
- }
- //Run program if end temp is smaller than start temp.
- while ( temp1 < temp2 )
- {
- velocity=(.61*temp1)+331.3;
- cout << "At "<<temp1<<" degrees Celsius the veloicty of sound is ";
- cout.setf(ios::fixed);
- cout.setf(ios::showpoint);
- cout.precision(1);
- cout << velocity<< " m/s\n";
- temp1++;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement