I need a function that will go through below values and print out the highest value with its name. It is not hard to find the highest value which is 20 but I can’t figure out a way to display the name of the value. Thank you!
Example:
North: 5
South: 10
West: 15
East :20
Output:
Winner is East with $20 in sales!
Here is what I got so far
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
double northeast, northwest, southeast, southwest;
// Function prototype
double getSales(string);
void findHighest();
int main()
{
northeast = getSales("Northeast");
northwest = getSales("Northwest");
southeast = getSales("Southeast");
southwest = getSales("Southwest");
return 0;
}
//Function getSales
double getSales(string name)
{ cout << "What is the quarterly sales figure for " << name << "? ";
double sales;
cin >> sales;
while (sales < 0)
{
cout << "Please enter a positive value ";
cin >> sales;
}
return sales;
}
// Function getHighest
void getHighest()
{
}
thank you for your responses. Following was the answer I was looking for.