Appendix

About

This section is included to assist the students to perform the activities present in the book. It includes detailed steps that are to be performed by the students to complete and achieve the objectives of the book.

1. Getting Started

Activity 1: Obtaining the Minimum of Two Numbers

Solution

  1. Declare 3 double variables: a, b, and m. Initialize them with the values 3, 4 and 0 respectively

    double a = 3;

    double b = 4;

    double m = 0; // variable for the minimum

  2. Create a String variable r, it should contain the output message to be printed.

    // string to be printed

    String r = "The minimum of numbers: " + a + " and " + b + " is ";

  3. Use the min() method to obtain the minimum of the two numbers and store the value in m.

    // mathematical operation ...

Get The Java Workshop now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.