User Defined Functions

In my class I am supposed to write a program with user defined constants and user defined functions. We are given tuition cost of $50 per credit hour and a one time technology fee of $10. I am stuck on how to implement/call user defined functions.

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
#include "stdafx.h"

const double TECHFEE = 10.00,
	         CREDITCOST = 50.00; //User defined constants?

int _tmain(int argc, _TCHAR* argv[])
{       
	double credits = 0,
		   cost;

	cout << "Please enter the number of credits you wish to take: "; 
	cin >> credits; 
	cout << endl;
	totalCost(TECHFEE,CREDITCOST,credits);
	cout << " The total tuition cost this semester is " << cost;
	

	system("PAUSE");
	return 0;
}

double totalCost(double TECHFEE, double CREDITCOST, double credits)
{ 
	double cost = 0;
	cost = (CREDITCOST * credits) + TECHFEE;
	return cost;
}
//I feel as though this whole defined function is typed incorrectly. 
Last edited on
closed account (2UD8vCM9)
try changing line 14
 
totalCost(TECHFEE,CREDITCOST,credits);


to

 
cost = totalCost(TECHFEE,CREDITCOST,credits);
It says totalCost identifier not found. Was I supposed to make a prototype somewhere?
closed account (2UD8vCM9)
Yes, before int main()

put

 
double totalCost(double TECHFEE, double CREDITCOST, double credits);
Edit: Nevermind I figured it out! Thanks again Pin!
Last edited on
Topic archived. No new replies allowed.