Highest division quarterly

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
// Includes
#include "stdafx.h"
#include <iostream>
using namespace std;

// Prototypes
double getSales(double & quarterly);
void findHighest();

//Main Funtion
int main()
{
	double quarterly;

	cout << "This will display the highest quarterly pay of 4 divisions.\n\n";

	getSales(quarterly);

	cout << "\n\nThe highest division quarterly is $" << endl;

	cout << endl << "Press ENTER to continue...";
	cin.clear();
	cin.sync();
	cin.get();
	
	return 0;
}
// Gets users input
double getSales(double & quarterly)
{
	float NE, SE, NW, SW;

	cout << "Enter northeast division quarterly pay: $";
	cin >> NE;
	cout << "Enter southeast division quarterly pay: $";
	cin >> SE;
	cout << "Enter northwest division quarterly pay: $";
	cin >> NW;
	cout << "Enter southwest division quarterly pay: $";
	cin >> SW;

	while ( NE < 0 || SE < 0 || NW < 0 || SW < 0 )
	{
		cout << "Please re-enter your pay quarterlys, they must be greater than 0.\n\n";
		cout << "Enter northeast division quarterly pay: $";
		cin >> NE;
		cout << "Enter southeast division quarterly pay: $";
		cin >> SE;
		cout << "Enter northwest division quarterly pay: $";
		cin >> NW;
		cout << "Enter southwest division quarterly pay: $";
		cin >> SW;
	}
	return quarterly;
}



Heres my code so far, everythings works, now i need this part of my exercise done, and its alittle confusing.

the last part says

Function void findHighest() is passed the four sales totals. It determines which division is the largest and prints the name of the highest grossing division, along with its sales figure.

Whats confusing is how i would make that function then get the function to determine which division has the largest pay.

The four division are Northeast, Southeast, Northwest, and Southwest.

Any ideas.
I doubt you getSales() function is working because you don't modify the input argument quarterly. If I understand well your function should take four float and fill them with user unput but your function does nothing with the input.
ok, how would i fix that and make the void findHighest() function.
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
// Includes
#include "stdafx.h"
#include <iostream>
using namespace std;

// Prototypes
double getSales(double & quarterly);
//void findHighest();

//Main Funtion
int main()
{
	double quarterly;

	cout << "This will display the highest quarterly pay of 4 divisions.\n\n";

	cout.setf(ios_base::fixed , ios_base::floatfield);
	cout.precision(2);

	getSales(quarterly);

	cout << endl << "Press ENTER to continue...";
	cin.clear();
	cin.sync();
	cin.get();
	
	return 0;
}
// Gets users input
double getSales(double & quarterly)
{
	float NE, SE, NW, SW;

	cout << "Enter northeast division quarterly pay: $";
	cin >> NE;
	cout << "Enter southeast division quarterly pay: $";
	cin >> SE;
	cout << "Enter northwest division quarterly pay: $";
	cin >> NW;
	cout << "Enter southwest division quarterly pay: $";
	cin >> SW;

	while ( NE < 0 || SE < 0 || NW < 0 || SW < 0 )
	{
		cout << "Please re-enter your pay quarterlys, they must be greater than 0.\n\n";
		cout << "Enter northeast division quarterly pay: $";
		cin >> NE;
		cout << "Enter southeast division quarterly pay: $";
		cin >> SE;
		cout << "Enter northwest division quarterly pay: $";
		cin >> NW;
		cout << "Enter southwest division quarterly pay: $";
		cin >> SW;
	}
	if ( NE > SE && NE > NW && NE > SW )
		cout << "\n\nNortheast division has the highest quarterly of $" << NE << endl;
	else if ( SE > NE && SE > NW && SE > SW )
		cout << "\n\nSoutheast division has the highest quarterly of $" << SE << endl;
	else if ( NW > NE && NW > SE && NW > SW )
		cout << "\n\nNorthwest division has the higest quareterly of $" << NW << endl;
	else 
		cout << "\n\nSouthwest division has the highest quarterly of $" << SW << endl;
	
	return 1;
}
// Find Highest quarterly function
void findHighest()
{
	double quarterly;

	cout << getSales(quarterly) << endl;
}


Here's my updated code.

eveerything works fine, but i need to know if my void findhighest() function is correct.

Remember i need the 4 division quarterlys passed to the findHighest function and that function is suppose to find the highest.
Last edited on
i need the 4 division quarterlys passed to the findHighest function

Here I see your findHighest function takes no arguments so it can be right.

Plus, as I said earlier, what is the purpose of the quarterly argument of the getSales function if you don't modify or use it?

From what you said the prototype of getSales should be
 
void getSales(double & NE, double& SE, double& NW, double& SW);

and findHighest should be
 
double findHighest(double NE, double SE, double NW, double SW);
oh ok, i understand now, i see what you meant thank you.
Topic archived. No new replies allowed.