Ask your own question, for FREE!
Computer Science 11 Online
OpenStudy (anonymous):

Hey I'm working on a code where I have to use the grow method to double the size of an existing rectangle. my first rectangle is Rectangle recOne = new Rectangle(10, 15, 5, 8); as you can see my width is 5 and height is 8. I further proceeded to do this : recOne.grow(5, 4); since the grow method is (width + 2h, heigth + 2v) The result I'm receiving for the new rectanlge is (9, 16) and not (10, 16). A friend of mine who is more advanced in coding told me this had to do with integer division.

OpenStudy (anonymous):

sorry that's recOne.grow(5/2, 4)

OpenStudy (rsmith6559):

5 / 2 in integer division equals 2. Any fraction is truncated (cut off). The plus side to this is that 5 % 2 = 1, the modulus ( remainder ) is one.

OpenStudy (pradius):

If you are using C++ you might just add decimal points to your elements and deal with float datatypes..

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!