Hi....
This is the function:
static void sumFun (float num1, float num2) throws IOException
{
BufferedReader read = new BufferedReader( new InputStreamReader(System.in));
String strNum1, strNum2;
System.out.println("Enter the first number: ");
strNum1 = read.readLine();
System.out.println("Enter the second number: ");
strNum2 = read.readLine();
num1 = Float.parseFloat(strNum1);
num2 = Float.parseFloat(strNum2);
}
This is in the main>> switch statement>> case1:
case 1:
sumFun(num11,num22);
System.out.println("The sum of " + (num11 + num22));
break;
And I have defined these before the switch statement:
float num11, num22;
But I received this error:
variable num11 might not have been initialized
variable num22 might not have been initialized
What's the wrong??
This is the function:
static void sumFun (float num1, float num2) throws IOException
{
BufferedReader read = new BufferedReader( new InputStreamReader(System.in));
String strNum1, strNum2;
System.out.println("Enter the first number: ");
strNum1 = read.readLine();
System.out.println("Enter the second number: ");
strNum2 = read.readLine();
num1 = Float.parseFloat(strNum1);
num2 = Float.parseFloat(strNum2);
}
This is in the main>> switch statement>> case1:
case 1:
sumFun(num11,num22);
System.out.println("The sum of " + (num11 + num22));
break;
And I have defined these before the switch statement:
float num11, num22;
But I received this error:
variable num11 might not have been initialized
variable num22 might not have been initialized
What's the wrong??