Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return value error

Status
Not open for further replies.

Tahoe

Programmer
Joined
Sep 24, 2002
Messages
4
Location
US
Beginning programmer...I keep getting a missing return value error on the following block of code.

/**
* Calculates the season charge based on the size of the lawn
*/
public String calculateCost()
{
double cost;
double area = calculateArea();


if(area < 400)
cost = 25*NUM_OF_WEEKS;
if(area > 400 || area < 600)
cost = 35*NUM_OF_WEEKS;
else
cost = 50*NUM_OF_WEEKS;
return;
}

Even if I indicate return cost;, I get another type of error. Any suggestions??

Thanks in advance...
 
your method is returning a String. Hence, you need to do this:-

public String calculateCost(){

String returnResult = null;

//Your function here

return returnResult;
}

~za~
You can't bring back a dead thread!
 
It compiled! Thanks again!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top