help with void functions

hi i know im calling these functions incorrectly in some way, but shouldnt my first two functions in main call correctly? sorry if this seems trivial!

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
using namespace std;

double rate;
int curr_selection;
double input;


void currencycheck()
{

	cout<<"Please enter the currency you would like to convert to\n";
	cout<<"(1)Euros\n";
	cout<<"(2)Pounds\n";
	cin>>curr_selection;
	if (curr_selection!=1&&curr_selection!=2)
	{
		cout<<"Invalid selection\n";
		cout<<"Please enter your selection again\n";
		cin>>curr_selection;
	}
}

void ratecheck()
{
	
	cout<<"Please enter the exchange rate you would like to use\n";
	cout<<"Enter (-1) for default rate\n";
	cin>>rate;
	if (rate==-1)
	{
		rate=1.144;
	}
}

double amount(double)
{
	cout<<"Please enter the amount you would like to convert\n";
	cin>>input;
	return input;
}

double conversion(double)
{
	double result;
	result=input*rate;
	if (curr_selection==1)
	{ 
		cout<<1/result;
	}
	else
	{
	cout<<result;
	}
	return result;
}

int main()
{
	currencycheck;
	ratecheck;
	amount;
	conversion;
	system("pause");
	return 0;
}
currencycheck;
ratecheck;
amount;
conversion;

You forgot the ()
Fixed code below

1
2
3
4
5
6
7
8
9
int main()
{
	currencycheck();
	ratecheck();
	amount();
	conversion();
	system("pause");
	return 0;
}
so I am begginer too but things i see are 1) you need to put brackets in the main function when you call some function.. so it should be like this:
1
2
3
4
5
6
7
8
9
int main()
{
	currencycheck();
	ratecheck();
	amount();
	conversion();
	system("pause");
	return 0;
}

and when you do amount function and conversion you don t need to put
(double) 
in the brackets.

and second i am not realy sure that your conversion from pound to euro is ok.. i would do it like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
double conversion()
{
	double result;
	
	if (curr_selection==1)
	{ 
                result = input/rate
		cout<<result;
	}
	else
	{
	result=input*rate;
        cout << result;
	}
	return result;
}


i hope i helped..
Topic archived. No new replies allowed.