CSE110: Principles of Programming with Java LAB 1 solution

$14.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

Please Note: Do not spend a lot of time trying to match the output with the sample output. You can assign values that you like.
When you see //—, this is where you need to add code. Please read the comments to have an idea to add what.

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: