Ugh...any C++ help??
what do you mean?
I'm taking a language class and have a very simple problem but the code fails. Looking for advice
I can try to help you out. I know some C++
OK...sec
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
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; }
This is the first week of the term and if I'm this lost I dunno :S
Hold on!
i also need ur help
cn u pls tell me the program to reverse pyramid of numbers
OK...I really appreciate the help
Uhm...thanks for posting in my thread Angel. LOL
sorry compiler is running slowler than usual
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
what compile error you getting?
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); ^
have you tried including the math function?
what do you mean?
#include <math.h> I haven't done C++ in a while, i'm trying!
Like I said. I appreciate the help. Let me try
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.
// 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 );
you need to include cmath to use the pow function. #include <cmath> http://www.cplusplus.com/reference/cmath/
#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) );
Join our real-time social learning platform and learn together with your friends!