Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m looking for help setting up a program, which is my first ever. I\'m kind of

ID: 3636785 • Letter: I

Question

I'm looking for help setting up a program, which is my first ever. I'm kind of lost and looking for some help

I need to write a program that calculates the speed of sound in fresh h_2_0. Given: temp, distance to an object, and time it takes to return at that temp.

The function is:

c=c_0 + c_1*T + c_2*T^2 + c_3*T^3 + c_4*T^4 + c_5*T^5

>>c represents speed of sound in fresh h_2_0, in m/s
>>T is the temperature of h_2_0, in degrees Celsius in the range 0 to 95
>>c_0 to c_5:
c0=1402
c1=5
c2=-.05
c3=.3*10^-3
c4=-.14*10^-5
c5=.32*10^-8

The program should do the following in order:

I) ask user for temp of h_2_0 in degrees C and time required for the sonar to return
-each should be entered separately, with its own question and answer

II) after performing the calculations, the program should report the results, including an echo of user's input .


Please help me get started with this, thank you.

Explanation / Answer

please rate - thanks

//I think it's self explanatory

if you learned a loop so temps must be in the range

#include <iostream>
#include <cmath>
using namespace std;
int main()
{double T, time,c;
double c0=1402;
double c1=5;
double c2=-.05;
double c3=.3*pow(10.,-3);
double c4=-.14*(10.,-5);
double c5=.32*(10.,-8);
cout<<"enter temp of h_2_0 in degrees C in the range 0 to 95: ";
cin>>T;
while(T<0||T>95)
   {cout<<"must be between 0 and 95 ";
   cout<<"enter temp of h_2_0 in degrees C in the range 0 to 95: ";
   cin>>T;
   }
cout<<"enter time required for the sonar to return: ";
cin>>time;
c=c0 + c1*T + c2*pow(T,2) + c3*pow(T,3) + c4*pow(T,4) + c5*pow(T,5);
cout<<"Temp: "<<T<<" degrees Celsius ";
cout<<"Time for sonar to return: "<<time<<endl;
cout<<"Speed of sound in this environment: "<<c<<endl;  
system("pause");
return 0;
}

-------------------------------------------

if you haven't learned the loop

#include <iostream>
#include <cmath>
using namespace std;
int main()
{double T, time,c;
double c0=1402;
double c1=5;
double c2=-.05;
double c3=.3*pow(10.,-3);
double c4=-.14*(10.,-5);
double c5=.32*(10.,-8);
cout<<"enter temp of h_2_0 in degrees C in the range 0 to 95: ";
cin>>T;
cout<<"enter time required for the sonar to return: ";
cin>>time;
c=c0 + c1*T + c2*pow(T,2) + c3*pow(T,3) + c4*pow(T,4) + c5*pow(T,5);
cout<<"Temp: "<<T<<" degrees Celsius ";
cout<<"Time for sonar to return: "<<time<<endl;
cout<<"Speed of sound in this environment: "<<c<<endl;  
system("pause");
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote