Function not being Called

Hey guys! I'm working on an assignment for my Computer Science course in college. I've currently ran into a problem with functions. For some reason I can't get the void function to get called into main. It only shows the first function being called. Anyone know how I can fix this?

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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <stdlib.h>

using namespace std;

// Global Variables

 string 	ne = "Northeast",
			se = "Southeast",
			nw = "Northwest",
			sw = "Southwest";

 double 	north_east,
			south_east,
			north_west,
			south_west;
		
// Function Prototypes

double getSales(string division); 
void findHighest(double, double, double, double); 

int main()
{
			
 cout << "================================" << endl;
 cout << "        Winning Division        " << endl; 
 cout << "================================" << endl;
 
 cout << endl << endl; 
 cout << "Division Sales: ";
 cout << endl << endl; 
 
// Calling on Input Function  
	
 north_east = getSales(ne);
 south_east = getSales(se);
 north_west = getSales(nw);
 south_west = getSales(sw);
 
 cout << endl << endl; 
 
 void findHighest (double north_east, double south_east, double north_west, double south_west);

}

// Input Function 

 double getSales(string division) 
 { 
	double sales;
	
	do 
	{
		cout << "Enter " << division << " Divsion Quartely Sales: $ ";
			cin >> sales;
		
	} while (sales < 0.0);
	return sales;
		
 }

// Output Function

 void findHighest (double north_east, double south_east, double north_west, double south_west)
 {
	double highest_sales = north_east;
	string highest_division = "Northeast";
	
	if (south_east >= highest_sales)
	{
		highest_sales = south_east; 
		highest_division = "Southeast";
	} 
	if (north_west >= highest_sales)
	{
		highest_sales = north_west; 
		highest_division = "Northwest";
	} 
	if (south_west >= highest_sales)
	{
		highest_sales = south_west; 
		highest_division = "Southwest";
	} 
	
	cout << endl << endl; 
	
 }

In main you cant have void infront of findHighest. Should look like:
findHighest (double north_east, double south_east, double north_west, double south_west);

not

void findHighest (double north_east, double south_east, double north_west, double south_west);
void findHighest (double north_east, double south_east, double north_west, double south_west);
you use this format to declare and/or define functions, to actually call functions you should not have the datatype identifiers, so it should be just:
findHighest (north_east, south_east, north_west, south_west);
That said your code is quite error-prone and depends on getting the order of user-input just right. A more robust approach would be to do something like:
1
2
3
4
5
struct Sales
{
	std::string m_division;
	double m_salesFigures;
}

Then you could sort Sales objects by m_salesFigures using std::vector<Sales> and as the names are attached to the sales figures there would be no ambiguity which figures belong to which division
Topic archived. No new replies allowed.