Error calling function

The code below is currently unfinished. It's eventually going to calculate tuition via how many credits you are taking. My problem is that when I try to build and run my code, I seem to get an error in the main function when I call COMPUTE_CHARGES and I can't figure out why. It apparently has something to do with the "double credits" but I'm not sure what it could be exactly.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
    # include<iostream>
using namespace std;
void DISPLAY_HEADER();
double GET_CREDITS();
double COMPUTE_CHARGES(double credits);
int main()
{
  DISPLAY_HEADER();
  GET_CREDITS();
  COMPUTE_CHARGES(double credits);
}
void DISPLAY_HEADER()
{
    cout << "Welcome to our University!\n";
}
double GET_CREDITS() //receiving input
{
    double credits;
    cout<<"Please enter the amount of credits you are taking: ";
    cin >> credits;
    if (credits > 24)//If you take more than 24 credits...
    {
        cout<<"You cannot take more than 24 credits";
    }
}
double COMPUTE_CHARGES(double credits)//Compute charge
{
    int baseprice = 110;
    double tuition;
        if (credits < 12) //Less than 12
    {
        tuition = (((credits*2)*214.50)+baseprice);
    }
    else if ((credits >= 12) && (credits <= 18)) //Between 12 and 18
    {
        tuition = (baseprice + 5500);
    }
    else if ((credits > 18) && (credits <= 24))//Between 18 and 24
    {
        tuition = ((((credits - 18)*2)*187.50)+baseprice + 5500);
    }
closed account (1CfG1hU5)
COMPUTE_CHARGES should be passed a value of type double. but not the words "double credits" declared in the prototype above main() and the function below main().

get_credits should probably return a value to main of "credits" and then passed to compute_charges.

return credits;

and

then compute_charges(credits);

also, main() is an integer function, so should have a value returned.

after

display_header();
get_credits();
compute_charges();
return 0; // 0 equals no error

get_credits(); and compute_charges(); are type 'double' and should return values.

Topic archived. No new replies allowed.