Help with program using multiple functions/variables

M

mattyizzo

Here is my code. Basically I'm trying to solve for CI and CF, where
each use a bunch of constants and a variable or two which can have up
to 10 values. I get the following error, however, at line 39:

39 H:\Project 2-PartialComplete5-7.cpp invalid operands of types
`double ()(double)' and `const double' to binary `operator/'

The error itself is at the equation starting with dQ = ... Any ideas,
suggestions?
Here is my code:

// Project 2

#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <cmath>
#include <math.h>
using namespace std;

const double a = 0.05; // Constants Declared
const double L = 100; // Constants Declared
const double Ta = 150; // Constants Declared
const double k = 0.1; // Constants Declared
const double F = 3.0; // Constants Declared
const double Cvol = 325; // Constants Declared
const double CL = 1.50; // Constants Declared
const double CstHeat = 0.00000000111; // Constants Declared

double b(double thick); // Function Declaration
double CI(double thick); // Function Declaration
double CF(double thick, double Tair); // Function Declaration

double b(double thick) // Function 'b' Starts
{
return (a+thick);
}

double CI(double thick) // Function 'CI' Starts
{
return ((b(thick)*b(thick))-(a*a))*L*Cvol + (L+CL);
}

double CF(double thick, double Tair) // Function 'CF' Starts
{
double Q3;
double dQ;

Q3 = 2*3.14*a*F*(Ta-Tair)*L;
dQ = Q3*(1-((b/a)/(1+((b*F)/k*(log(b/a))))));
return dQ*(157800000)*(CstHeat);
}

int main () // Main Function Start
{
double thick; // Variables Declared
double Tair; // Variables Declared

double b(double thick); // Call Function
double CI(double thick); // Call Function
double Q3(double Tair); // Call Function

for (thick = 1.0; thick <=10.0; thick +=1.0) // for loop
{
cout << CI(thick) << endl;
}

for (Tair = -10; Tair <=10; Tair +=10)
{
cout << Q3(Tair) << endl;
}

system ("pause");
}
 
M

mattyizzo

Ok, so my problem was that I created a function 'b' in which I
returned the value of b (which in this program, is 'thick' + 'a'.

So instead of using the function within the CF function, I replaced
'b' with 'a+thick'.

My next problem is I have to print out a table of the CI function, the
CF function, and then somehow a table that shows CF-CI (but the
problem here is that CI has 10 values, and CF has 3...
 
K

Krice

(e-mail address removed) kirjoitti:
const double a = 0.05; // Constants Declared
double b(double thick); // Function Declaration
double b(double thick) // Function 'b' Starts
double thick; // Variables Declared
double b(double thick); // Call Function

Slightly off-topic, but I really love your comments.
 
M

mattyizzo

(e-mail address removed) kirjoitti:


Slightly off-topic, but I really love your comments.

Hahaha, are they not clear enough? I'm a beginner at this stuff, and
my project is due within 3 hours. Sucks to be a n00b.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top