0

i have this function that should compare values and return a string based on input from the main function. However it returns no value at all does anyone see and issue with it?


have checked all the input it is getting the correct values

highestMontName and averagedMonth are declared globally

month is a const int of 12


thanks for any ideas or help

string FindMax()
{
	string monthN;
	for(int i=0; i<month; i++)
	{
		if(averagedMonth[i]>highestMonthName)
		{	
			highestMonthName=i;
		}
	}

	//gets the month name
	if(highestMonthName == 0)
		monthN = "January";
	if(highestMonthName == 1)
		monthN = "February";
	if(highestMonthName == 2)
		monthN = "March";
	if(highestMonthName == 3)
		monthN = "April";
	if(highestMonthName == 4)
		monthN = "May";
	if(highestMonthName == 5)
		monthN = "June";
	if(highestMonthName == 6)
		monthN = "July";
	if(highestMonthName == 7)
		monthN = "August";
	if(highestMonthName == 8)
		monthN = "September";
	if(highestMonthName == 9)
		monthN = "October";
	if(highestMonthName == 10)
		monthN = "November";
	if(highestMonthName == 11)
		monthN == "Decemeber";

	return monthN;
}
3
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by alex55
0

try this.........

string FindMax()
{
	string monthN;
	for(int i=0; i<month; i++)
	{
		if(averagedMonth[i]>highestMonthName)
		{	
			highestMonthName=i;
		}
	

	//gets the month name
	if(highestMonthName == 0)
		monthN = "January";
	if(highestMonthName == 1)
		monthN = "February";
	if(highestMonthName == 2)
		monthN = "March";
	if(highestMonthName == 3)
		monthN = "April";
	if(highestMonthName == 4)
		monthN = "May";
	if(highestMonthName == 5)
		monthN = "June";
	if(highestMonthName == 6)
		monthN = "July";
	if(highestMonthName == 7)
		monthN = "August";
	if(highestMonthName == 8)
		monthN = "September";
	if(highestMonthName == 9)
		monthN = "October";
	if(highestMonthName == 10)
		monthN = "November";
	if(highestMonthName == 11)
		monthN == "Decemeber";

	return monthN;
}
}
0

nice catch on that

Yep line 36.
Assignment operator needed not comparism.
C++ Syntax (Toggle Plain Text)

1.
monthN = "Decemeber";

monthN = "Decemeber";
instead

but still no luck with the other problem

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.