-
functions ??? help
I am using a unix compiler and this is my program. I can not figure out where my problems are.
///////////////////////////////////////////////////////////////
// CSCI 201, Computer Science 1
// Fall 2001
//
// This program calculates the cooling rate of hot coffee
// compared to the cooling rate of warm coffee and then
// returns the ratio of that.
// Program Name: Program 4
// Programmer Name: Evan Siljander
// Date: 10/10/2001
///////////////////////////////////////////////////////////////
#include <iostream.h>
#include <iomanip.h>
#include <math.h>
#include <stdlib.h>
const float Kelvin = 273; // This is to convert Celsius to Kelvin
// Prototype Declarations for functions and procedures used
// in this program
///////////////////////////////////////////////////////////////
// This function asks the user for the room temperature,
// high temperature, and warm temperature. These values are
// returned to the calling program.
void prompt_user_for_input
(
float &room_temp, // post: room temperature
float &hot_coffee, // post: hot coffee temp
float &warm_coffee // post: warm coffee temp
);
///////////////////////////////////////////////////////////////
// This function calculates the hot coffee cooling rate given
// the hot coffee temperature and the room temperature.
void calculate_hot_rate
(
float &hot_rate, // post: hot coffee cooling
// rate
float hot_coffee, // pre: hot coffee temp
float room_temp // pre: room temperature
);
///////////////////////////////////////////////////////////////
// This function calculates the warm coffee cooling rate given
// the warm coffee temperature and the room temperature.
void calculate_warm_rate
(
float &warm_rate, // post: warm coffee
// cooling rate
float warm_coffee, // pre: warm coffee temp
float room_temp // pre: room temperature
);
///////////////////////////////////////////////////////////////
// This prints out the calculations
void print_the_calculations
(
float cooling_ratio
);
///////////////////////////////////////////////////////////////
//
void main ()
{
////////////////////////////////////////////////////////////
// These are for the input values
float room_temp; // Room temperature
float hot_coffee; // Hot coffee temperature
float warm_coffee; // Warm coffee temperature
////////////////////////////////////////////////////////////
// These are calculated
float hot_rate; // Based on room and hot
// coffee temperature
float warm_rate; // Based on room and warm
// coffee temperature
float cooling_ratio; // This is hot rate/warm rate
// These format the output nicely.
cout.setf( ios::fixed );
cout.setf( ios::showpoint );
// This does the work of the program.
cout << endl << endl;
prompt_user_for_input( room_temp,
hot_coffee,
warm_coffee );
// Calculate hot coffee cooling rate.
calculate_hot_rate( hot_rate,
hot_coffee,
room_temp );
// Calculate warm coffee cooling rate.
calculate_warm_rate( warm_rate,
warm_coffee,
room_temp );
// Finally calculate the cooling ratio.
cooling_ratio = hot_rate/warm_rate;
// Print out the calculations
print_the_calculations( cooling_ratio );
return 0;
}
void prompt_user_for_input
(
float &room_temp,
float &hot_coffee,
float &warm_coffee
)
{
cout << "This program will help you determine whether or not hot"
<< " coffee cools faster to room temperature the further its"
<< " temperature is from room temperature." << endl << endl;
cout << "What is the temperature of the room in degrees Celsius: ";
cin >> room_temp;
cout << endl;
cout << "What is the high temperature for comparison: ";
cin >> hot_coffee;
cout << endl;
cout << "What is the warm temperature for comparison: ";
cin >> warm_coffee;
cout << endl;
}
void calculate_hot_rate
(
float &hot_rate,
float hot_coffee,
float room_temp
)
{
hot_rate = (pow(hot_coffee + Kelvin),4)-(pow(room_temp + Kelvin),4);
}
void calculate_warm_rate
(
float &warm_rate,
float warm_coffee,
float room_temp
)
{
warm_rate = (pow(warm_coffee + Kelvin),4)-(pow(room_temp + Kelvin),4);
}
void print_the_calculations
(
float cooling_ratio
)
{
cout << "The ration of the cooling rate of the hot coffee to the"
<< " cooling rate of the warm coffee is " << cooling_ratio
<< endl << endl;
cout << "So who was correct?" << endl << endl;
cout << "That's all folks" << endl << endl;
}
Here are the errors:
/usr/local/lib/gcc-lib/alpha-dec-osf4.0d/2.8.1/include/math.h: In function `void
calculate_hot_rate(float &, float, float)':
/usr/local/lib/gcc-lib/alpha-dec-osf4.0d/2.8.1/include/math.h:147: too few argum
ents to function `double pow(double, double)'
prog04.cpp:155: at this point in file
/usr/local/lib/gcc-lib/alpha-dec-osf4.0d/2.8.1/include/math.h:147: too few argum
ents to function `double pow(double, double)'
prog04.cpp:155: at this point in file
/usr/local/lib/gcc-lib/alpha-dec-osf4.0d/2.8.1/include/math.h: In function `void
calculate_warm_rate(float &, float, float)':
/usr/local/lib/gcc-lib/alpha-dec-osf4.0d/2.8.1/include/math.h:147: too few argum
ents to function `double pow(double, double)'
prog04.cpp:165: at this point in file
/usr/local/lib/gcc-lib/alpha-dec-osf4.0d/2.8.1/include/math.h:147: too few argum
ents to function `double pow(double, double)'
prog04.cpp:165: at this point in file
-
You have missed a ')':
warm_rate = (pow(warm_coffee + Kelvin),4)-(pow(room_temp + Kelvin),4);
should be:
warm_rate = (pow((warm_coffee + Kelvin),4)-(pow((room_temp + Kelvin),4);
-
Thank you!!
This solution was actually missing another )
warm_rate = (pow((warm_coffee + Kelvin),4)-(pow((room_temp + Kelvin),4);
should've been:
warm_rate = (pow((warm_coffee + Kelvin),4))-(pow((room_temp + Kelvin),4));
But without your help, i would've been at if for hours. Thank you