1. Chapter 2 Elementary ProgrammingLiang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. 01321308071 2. Motivations…