I really can't figure out why my code is causing this error, everything looks correct, thought it keeps coming up as it is missing a return statement }
I tried looking for solutions, and I saw that "while" after "if" is one solution, but since I need multiple numbers I cannot use while, and have to go with "what if"
Could anyone help me out?
import java.util.*;
class WS8Q4
{
public static void main (String[] args)
{
Scanner in = new Scanner(System.in);
int x = 0;
System.out.println("Please put in an integer from 0 - 9");
x = in.nextInt ();
String answer = numTxt (x);
System.out.println(answer);
}
public static String numTxt (int x)
{
if (x==0)
{
return ("Zero");
}
else if (x==1)
{
return ("One");
}
else if (x==2)
{
return ("Two");
}
else if (x==3)
{
return ("Three");
}
else if (x==4)
{
return ("Four");
}
else if (x==5)
{
return ("Five");
}
else if (x==6)
{
return ("Six");
}
else if (x==7)
{
return ("Seven");
}
else if (x==8)
{
return ("Eight");
}
else if (x==9)
{
return ("Nine");
}
}
}