finding highest number without array

#include<iostream>
#include<string>
using namespace std;



double getsales();
double findhighest(double,double,double,double);


int main()
{
start:

char restart;
double Nsales =0,Ssales=0,Wsales=0,Esales=0,highest;


cout << "Northcoast sales." << endl;
Nsales = getsales();
cout << "Eastcoast sales." << endl;
Ssales = getsales();
cout << "Southcoast sales." << endl;
Wsales = getsales();
cout << "Westscoast sales." << endl;
Esales = getsales();


highest = findhighest(Nsales, Ssales, Wsales, Esales);



if((highest - Nsales) == 0)
cout << "N" << endl;

if((highest - Ssales) == 0)
cout << "S" << endl;

if((highest - Wsales) == 0)
cout << "W" << endl;

if((highest - Esales) == 0)
cout << "E" << endl;

cout << highest << endl;

do
{
cout << "Restart? Y/N" << endl;
cin >> restart;
} while(restart != 'Y' && restart != 'y' && restart != 'N' && restart != 'n');

if(restart == 'Y' || restart == 'y')
goto start;


system("PAUSE");
return 0;
}


double getsales()
{

double sales=0;

loop:
cout << "Enter the sales for the division (do not enter an amount less than 0)." << endl;
cin >> sales;
if(sales < 0)
goto loop;

return sales;
}

double findhighest(double Nsales,double Ssales,double Wsales,double Esales)
{

double highest = Nsales;

if(Ssales > highest)
highest = Ssales;

if(Esales > highest)
highest = Esales;

if(Wsales > highest)
highest = Wsales;

return highest;
}
The program is supposed to accept sales amounts from the user in regards to 4 sales divisions (North,East,South or West) and then display the highest number along with which division has the highest sales.
The code works partially, it will display the highest number but when it gets to the part where I want it to display which sales division has the highest sales (N,E,S or W) it always displays the wrong one for some reason.
== and double do not mix. There is almost always a small error and so it is almost always false

modify findhighest to get the division as well as the sales value

Do a higher and lower var...

Then equal lower to 9999999 and higher to 0 and star comparing each value

while(values)
if (value>higher)
higher=a

if(value<lower)
lower=a

in the end u'll have the higher and the lower value...
Topic archived. No new replies allowed.