here is the code:
import java.util.Scanner;
public class beersong
{
public static void main (String[] args)
{
int bottle;
int bottlenumber;
int bottlezero;
int i;
int bottletens;
int bottleones;
String bottleword;
Scanner scannerObject = new Scanner(System.in);
System.out.println("how many bottles of beer?");
bottle = scannerObject.nextInt();
if (bottle <= 0);
{
bottle = 0;
}
if (bottle > 99);
{
bottle = 99;
}
bottletens = bottle/10;
bottleones = bottle%10;
for (i = bottle; i > 0; i--)
{
System.out.println(i + " bottels of beer on the wall, " + i + " bottles of beer!");
System.out.println("you take one down you pass it around " + (i - 1) + " bottles of beer on the wall!");
}
System.out.println("the song is done");
}
String bottlewordString(int bottleNumber);
{
if (bottle < 20)
{
switch (bottleNumber)
{
case 1:
return "one";
case 2:
return "two";
case 3:
return "three";
case 4:
return "four";
case 5:
return "five";
case 6:
return "six";
case 7:
return "seven";
case 8:
return "eight";
case 9:
return "nine";
case 10:
return "ten";
case 11:
return "eleven";
case 12:
return "twelve";
case 13:
return "thirteen";
case 14:
return "fourteen";
case 15:
return "fifteen";
case 16:
return "sixteen";
case 17:
return "seventeen";
case 18:
return "eighteen";
case 19:
return "nineteen";
default:
System .out .println("please enter a different number, and try again");
System.exit(0);
return "error"; //to keep the compiler happy
}
}
else
{
switch (bottletens)
{
case 2:
return "twenty";
case 3:
return "thirty";
case 4:
return "fourty";
case 5:
return "fifty";
case 6:
return "sixty";
case 7:
return "seventy";
case 8:
return "eighty";
case 9:
return "ninety";
default:
System .out .println("please enter a different number, and try again");
System.exit(0);
return "error"; //to keep the compiler happy
}
switch (bottleones)
{
case 1:
return "one";
case 2:
return "two";
case 3:
return "three";
case 4:
return "four";
case 5:
return "five";
case 6:
return "six";
case 7:
return "seven";
case 8:
return "eight";
case 9:
return "nine";
default:
System .out .println("please enter a different number, and try again");
System.exit(0);
return "error"; //to keep the compiler happy
}
}
}
}
and here is the problem:
return "nine";
^
error: return outside of methood
what do i do?