## Description

1. Type the following file into TextPad adding your name and lab letter. Make sure your file is

called Lab1.java. Don’t copy and paste the code. It does not work if you copied it.

//***********************************************************

// Name: Your Name here

// Lab Letter: X

// Title: Lab1.java

// Description: Mathematical Operations

// Time spent: Time taken to complete the assignment

// Date: 08/29/2018

//***********************************************************

public class Lab1

{

public static void main (String[] args)

{

System.out.println(“This is my first program!”);

}

}

Compile and run the program. What is the output?

2. Mathematical operations::

i. ADDITION. SUBTRACTION, MULTIPLICATION, MODULUS

public class Lab1

{

public static void main (String[] args)

{

//—> Declare two integer variables.

System.out.println(“This is my first program!”);

/* Example*/

System.out.println(“Sum of the two numbers : ”+(num1 + num2));

//—> Add the console outputs for all other operations.

}

}

Let’s do the rest of the operations now! Apply the operators and print the output on the

console.

ii. USING THE MATH CLASS::

Lets calculate the area of a circle using some of the mathematical operations available

in java.lang.Math class.

public class Lab1

{

public static void main (String[] args)

{

//—> Declare two integer variables.

System.out.println(“This is my first program!”);

/* Example*/

System.out.println(“Sum of the two numbers : ”+(num1 + num2));

//—> Add the console outputs for all other operations.

//—> Declare the radius variable and assign a value.

//—> Print the radius.

//—> You may use a separate variable to store the result(area). If you are, then

declare. Else you can simply append.

//—> Print the result.

}

}

The sample output should be like:

This is my first program!

Sum:

Product:

Division:

Modulus:

Value of the radius: 4

Area of the circle: 50.26548245743669