#include <iostream>
#include <string>
using namespace std;
float input_div(string);
void findHighest(float, float, float, float);
int main()
{
	float nE, sE, nW, sW;

	nE = input_div( "North East" );	
	sE = input_div( "South East" );	
	nW = input_div( "North West" );	
	sW = input_div( "South West" );	

	findHighest(nE, sE, nW, sW); //prints the result also
	return 0;
}
float input_div(string)
{
     float entry;
     cout << "Enter the sales for " << "North East" << " Division: ";
     cin >> entry;
     return entry;
}

void findHighest (float nE, float sE, float nW, float sW)
{
  string highest, name;
  highest = nE;
  name = "North East";

	if(sE > highest)
      {
		highest = sE;
		name = "South East";
      }

	if(nW > highest)
      {
		highest = nW;
		name = "North West";
      }

	if(sW > highest)
      {
		highest = sW;
		name = "South West";
      }

	cout << "the highest is " << name << " with" << highest << "\n\n";
}

ALRITE. THIS IS MY PROGRAM. WHEN I RUN, I AM GETTING AN ERROR WHERE IT SAYS highest = NE; ANY IDEA FOLKS? THX FOR ALL DA HELP:)

What does the error message tell you? The answer you need is probably right there in the message.

At least, look at the line the error message points you to, and carefully examine what your code is doing, versus what you think it's doing.

Hi

I AM GETTING AN ERROR WHERE IT SAYS highest = NE

You decleared highest as "string" type but assigning float value to that . highest = NE That's the problem

I guess your intention is to output the highest number amoung the four.if it so, you have to decalare hightest as float type. that is float highest; one more thing I think decalaring this function with string as argument is no need
float input_div(string);
because you are not all using the passed string in that function(not even have a parameter to assign itself).

even if you declare and invoke without parameter as float input_div();
it will work.

greetings
Parthiban

hey pratibhan,
tht fixed my error. thx a lott. but my goal for this program is tht program should ask me to enter the sales for nE, sE, nW, and sW then it should calculate which division in a company had the greatest sales
for a quarter.? with current program, when i run, it ask me to enter sales for nE for four times, any idea?

Hi koolboy ,

with current program, when i run, it ask me to enter sales for nE for four times, any idea?

That's a simple problem .Actually your are getting four inputs for each division but that problem is due to the statement cout << "Enter the sales for " << "North East" << " Division: "; for each division when you call input_div() that statement is printed .so if you put whatever in that statement it will be simply printed for every call(in your case for each division).

To resolve that :

declare input_div as

#include <iostream>
#include <string>
using namespace std;
float input_div(string);

and call as you called before

nE = input_div( "North East" );    
    sE = input_div( "South East" );    
    nW = input_div( "North West" );    
    sW = input_div( "South West" );

and make input div() as follows

loat input_div(string div_name)
{
     float entry;
     cout << "Enter the sales for " << div_name<< " Division: ";
     cin >> entry;
     return entry;
}

what you are doing is :
The string (name of the division) you passed to input_div() is now assigned to div_name string variable which will display appropriate division name for each call.

greetings
Parthiban

This article has been dead for over six months. Start a new discussion instead.