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
- 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
- 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 ";
- 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 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.