Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (anonymous):

Ugh...any C++ help??

OpenStudy (anonymous):

what do you mean?

OpenStudy (anonymous):

I'm taking a language class and have a very simple problem but the code fails. Looking for advice

OpenStudy (anonymous):

I can try to help you out. I know some C++

OpenStudy (anonymous):

OK...sec

OpenStudy (anonymous):

The problem is: (Science: wind- chill temperature) How cold is it outside? The temperature alone in not enough to provide an answer. Other factors including wind speed, relative humidity, and sunshine play important roles in determining coldness outside. In 2001, the National Weather Service (NWS) implemented the new wind chill temperature to measure the coldness using temperature and wind speed. The formula is given as follows: Twc = 35.74 + 0.6215ta – 35.75v0.16 +0.4275tav0.16 Where ta is the outside temperature measured in degrees Fahrenheit and v is the speed measured in miles per hour. Twc is the wind chill temperature. The formula cannot be used for wind speeds below 2 mph or temperatures below -58 F or above 41 F. Write a program that prompts the user o enter a temperature between -58 F and 41 F and a wind speed greater than or equal to 2 and displays the wind chill temperature. Use Math.pow(a, b) to compute v0.16

OpenStudy (anonymous):

I wrote: #include <iostream> using namespace std; int main() { // Enter the temperature in Fahrenheit cout << "Enter the temperature in Fahrenheit: "; double ta; cin >> ta; // Prompt the user to enter wind speed in miles per hour cout << "Enter the wind speed in miles per hour: "; double v; cin >> v; double U = 35.74 + (0.6215 * ta) - 35.75 pow(v,0.16) + 0.4275 * ta * pow(v, 0.16); //Display Result cout << "The Wind Chill index " << U << " is " << ta << " temperature " << endl; return 0; }

OpenStudy (anonymous):

This is the first week of the term and if I'm this lost I dunno :S

OpenStudy (anonymous):

Hold on!

OpenStudy (anonymous):

i also need ur help

OpenStudy (anonymous):

cn u pls tell me the program to reverse pyramid of numbers

OpenStudy (anonymous):

OK...I really appreciate the help

OpenStudy (anonymous):

Uhm...thanks for posting in my thread Angel. LOL

OpenStudy (anonymous):

sorry compiler is running slowler than usual

OpenStudy (anonymous):

No worries...it doesn't help I've been staring and reading the book for hours. I think I'm just tired and missing something simple

OpenStudy (anonymous):

what compile error you getting?

OpenStudy (anonymous):

error: expected ',' or ';' before 'Math' double U = 35.74 + (0.6215 * ta) - 35.75 Math.pow(v,0.16) + 0.4275 * ta * Math.pow(v, 0.16); ^

OpenStudy (anonymous):

have you tried including the math function?

OpenStudy (anonymous):

what do you mean?

OpenStudy (anonymous):

#include <math.h> I haven't done C++ in a while, i'm trying!

OpenStudy (anonymous):

Like I said. I appreciate the help. Let me try

OpenStudy (mandre):

You need to change your code to prevent entry of numbers outside your limits provided. I think the simplest way would be to use a WHILE statement to loop until the user enters valid numbers.

OpenStudy (mandre):

// Enter the temperature in Fahrenheit double ta=0; do { cout << "Enter the temperature in Fahrenheit (-58 to 41): "; cin >> ta; } while (ta < -58 || ta > 41 );

OpenStudy (anonymous):

you need to include cmath to use the pow function. #include <cmath> http://www.cplusplus.com/reference/cmath/

OpenStudy (rsmith6559):

#include <math.h> and #include <cmath> are basically the same (I think they are the same). math.h is C and cmath is C++. Anyway, what the compiler is complaining about in the error that you posted is the lack of an operator between 35.75 and Math. The line should compile with the include and: double U = 35.74 + (0.6215 * ta) - ( 35.75 * Math.pow(v,0.16) ) + ( 0.4275 * ta * Math.pow(v, 0.16) );

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!