In: Computer Science
Write a java code that takes 2 parameters input and output and and guesses value of 3 variables x,y,z for following equation:
output/input = (x)/(y*z)
and range of x = 2 to 512
and y and z = 2 to 32
for example public int method(int input, int
output)
and input was 10 and output was 80
it'll return x=32 and y=2 and z=2.
class GuessVal
{
   public static void guess_value(int input, int
output)
   {
       int k = output/input;
       int flag = 0;
       for(int x = 2;x <=512;x++)
       {
           for(int y = 2;y
<= 32;y++)
           {
          
    for(int z = 2;z <= 32;z++)
          
    {
          
        if(x/(y * z) == k)
          
        {
          
           
System.out.println("x is "+x+" y is "+y+" z is "+z);
          
            flag =
1;
          
           
break;
          
        }
          
    }
          
    if(flag == 1)
          
    {
          
        break;
          
    }
           }
           if(flag ==
1)
           {
          
    break;
           }
       }
   }
      
   public static void main(String args[])
   {
       int input,output;
       input = 10;
       output = 80;
       guess_value(input, output);
   }
}

If you have any doubts please comment and please don't dislike.