Current location - Training Enrollment Network - Mathematics courses - 48 chickens and rabbits; Their legs and feet are =108; Chicken =? Rabbit =? How to calculate in Java? What about math?
48 chickens and rabbits; Their legs and feet are =108; Chicken =? Rabbit =? How to calculate in Java? What about math?
Math:

Suppose that all rabbits, then? :

4? x? 48? =? 192? One leg.

Beyond reality:

192? -? 108? =? 84? One leg.

Besides, rabbits have two more legs than chickens:

4? -? 2? =? 2

So, dividing 2 by the extra legs is the number of chickens.

Chicken? =? 84? /? 2? =? 42? Only. ?

And we can know from the title that there are 48 chickens and rabbits. Now we know that there are 42 chickens. What? 48? -? So it's 42 years old? :

Rabbit? =? 48? -? 42? =? 6? only

Code:

Public? Class? test

{

Public? Static electricity Invalid? main(String[]? args)?

{

for(int? Chicken? =? 0; Chicken? & lt? 48; Chicken? ++)

{

int? Rabbit? =? 48? -? Chicken;

If (chicken *2? +? Rabbit *4? ==? 108)

{

System.out.println ("Number of chickens:"+chickens? +? "Number of rabbits:"+? Rabbit);

}

}

}

}