This is my code

import java.lang.Math; 
import java.io.*; 

public class TestDfunction { 

static void fun(float num1, float num2) throws IOException  
        { 
            BufferedReader read = new BufferedReader( new InputStreamReader(System.in)); 
         
            String strNum1, strNum2; 
             
            System.out.print("Enter the first number: ");  
            strNum1 = read.readLine(); 
            num1 = Float.parseFloat(strNum1); 
             
            System.out.print("Enter the second number: "); 
            strNum2 = read.readLine(); 
            num2 = Float.parseFloat(strNum2); 
         
        } 

   
static void menu() 
{ 
         
        System.out.println("Please choose the type of operation needs to be computed by pressing the corresponding number: ");
        System.out.println("----------------------------------------------------------------------------------------------");         
        System.out.println("                                    1.        Addition"); 
        System.out.println("                                    2.        Subtraction"); 
        System.out.println("                                    3.        Multiplication"); 
        System.out.println("                                    4.        Division"); 
        System.out.println("                                    5.        Remainder"); 
        System.out.println("                                    6.        Minimum"); 
        System.out.println("                                    7.        Maximum"); 
        System.out.println("----------------------------------------------------------------------------------------------");     
}       

    public static void main(String[] args) 
         
    { 
     
        menu();     
         
        try{ 
         
        BufferedReader read = new BufferedReader( new InputStreamReader(System.in)); 
         
            float num11, num22; 
            String strChoose; 
            int choose; 
             
            strChoose = read.readLine(); 
            choose = Integer.parseInt(strChoose); 
            System.out.println(""); 
         
        while ((choose <1) || (choose >8)) 
        { 
        System.out.println(); 
        System.out.println("The number you have entered is invalid..."); 
        menu(); 
        strChoose = read.readLine(); 
        choose = Integer.parseInt(strChoose);     
        } 
         
         
        switch (choose) 
        {     
             
        case 1:      
            fun(num11,num22); 
            System.out.println("The sum is: "+ (num11 + num22)); 
            break; 
             
         
        case 2:      
            fun(num11,num22); 
            System.out.println("The diferrence is: " + (num11 - num22)); 
            break; 
             
        case 3: 
            fun(num11,num22); 
            System.out.println("The product is: " + (num11 * num22)); 
            break; 
         
        case 4:      
            fun(num11,num22); 
            System.out.println("The quotion is: " + (num11 / num22)); 
            break; 

        case 5:      
            fun(num11,num22); 
            System.out.println("The remainder is: " + Math.IEEEremainder(num11,num22)); 
            break; 
             
        case 6:      
            fun(num11,num22); 
            System.out.println("The smaller value is: " + Math.min(num11,num22)); 
            break; 
             
        case 7:          
            fun(num11,num22); 
            System.out.println("The greater value is: " + Math.max(num11,num22)); 
            break; 
             
        case 8: 
             System.exit(0);                     
        } 
         
            }         
             
        catch (IOException e) {System.out.println("IO Error");} 
        } 
    }

Errors:
variable num11 might not have been initialized
variable num22 might not have been initialized

The error is pretty self explanatory. You never gave the variables a value.

float num11, num22;

That creates them but it does not initialize them with a value. If you give them a starting value, such as zero, your error is fixed; however your program does not work due to a logic error. Your method fun reads the values but never returns them. I think you should be able to figure it out from there.

This article has been dead for over six months. Start a new discussion instead.