© Ron Dai 2019
R. DaiLearn Java with Mathhttps://doi.org/10.1007/978-1-4842-5209-3_33

33. Java Intermediate Solutions

Ron Dai1 
(1)
Seattle, WA, USA
 

For your reference, in this chapter I’ll provide you with answer hints to some of the problems in the earlier chapters. For example, “For 16.” means “Hints for problems in Chapter 16.”

For 16. Pythagorean Triples

  1. 1.

    Instead of using “c,” we may check whether (a2 + b2) is a perfect square number, which is taking a square root of it and validating if it is an integer value.

     
  2. 2.

    Use the example code and check whether the resulting value of (a2 + b2) matches the form of “4n + 1”.

     

For 17. Strong Typed Programming

       public boolean isCollinear(Point p) {
              if (p.getX() == p1.getX() && p1.getX() ...

Get Learn Java with Math: Using Fun Projects and Games now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.