You are on page 1of 13

Prepared by: Edilberto L. Caralos Jr. FM-AA-CIA-15 Rev.

0 30-March-2021

Study Guide in SIA 101 Systems Integration and Architecture

Home-based Activity for Module 01

JAVA PROGRAMMING FUNDAMENTALS

Activity 01

PLEASE WRITE YOUR NAME HERE ↓


Last Name: _________________________ First Name: ______________________________ _______
Course, Year and Section: ___________________ 20
Date: ______________________________________ Score

Java Operators (10 points)


Operators are used to perform operations on variables and values. The value is called an operand,
while the operation (to be performed between the two operands) is defined by an operator:
Operand Operator Operand

100 + 50

In the example below, the numbers 100 and 50 Try to run this code:
are operands, and the + sign is an operator: //Java Operators Example 1
Example: public class MyClassJavaOperators1 {
int x = 100 + 50; public static void main(String[] args) {
int x = 100 + 50;
System.out.println(x);
}
}

This will produce an output:


150

Although the + operator is often used to add Try to run this code:
together two values, like in the example above, //Java Operators Example 2
it can also be used to add together a variable public class MyClassJavaOperators2 {
and a value, or a variable and another variable: public static void main(String[] args) {
int sum1 = 100 + 50;
Example: int sum2 = sum1 + 250;
// 150 (100 + 50) int sum3 = sum2 + sum2;
int sum1 = 100 + 50; System.out.println(sum1);
// 400 (150 + 250) System.out.println(sum2);
int sum2 = sum1 + 250; System.out.println(sum3);
// 800 (400 + 400) }
int sum3 = sum2 + sum2; }
This will produce an output:
150
400
800

Java divides the operators into the following groups:


 Arithmetic operators
 Assignment operators
 Comparison operators
 Logical operators

PANGASINAN STATE UNIVERSITY 1


Prepared by: Edilberto L. Caralos Jr. FM-AA-CIA-15 Rev. 0 30-March-2021

Study Guide in SIA 101 Systems Integration and Architecture

Now, it’s your turn…

Arithmetic Operators
Arithmetic operators are used to perform common mathematical operations.
Operator Name Description Example
+ Addition Adds together two values x + y`

Try to run this code: This will produce an output:


//Addition Operator _____________________________
public class MyClassAdditionOperator {
public static void main(String[] args) {
int x = 5;
int y = 3;
System.out.println(x + y);
}
}

- Subtraction Subtracts one value from another x-y

Try to run this code: This will produce an output:


//Sunbtraction Operator _____________________________
public class MyClassSubtractionOperator{
public static void main(String[] args) {
int x = 5;
int y = 3;
System.out.println(x - y);
}
}

* Multiplication Multiplies two values x*y

Try to run this code: This will produce an output:


//Multiplication Operator _____________________________
public class MyClassMultiplicationOperator {
public static void main(String[] args) {
int x = 5;
int y = 3;
System.out.println(x * y);
}
}

/ Division Divides one value from another x/y

Try to run this code: This will produce an output:


//Division Operator _____________________________
public class MyClassDivsion {
public static void main(String[] args) {
int x = 12;
int y = 3;
System.out.println(x / y);
}
}

% Modulus Returns the division remainder x%y

PANGASINAN STATE UNIVERSITY 2


Prepared by: Edilberto L. Caralos Jr. FM-AA-CIA-15 Rev. 0 30-March-2021

Study Guide in SIA 101 Systems Integration and Architecture

Try to run this code: This will produce an output:


//Modulo Operator _____________________________
public class MyClassModuloOperator {
public static void main(String[] args) {
int x = 5;
int y = 2;
System.out.println(x % y);
}
}

++ Increment Increases the value of a variable by 1 ++x

Try to run this code: This will produce an output:


//Increment Operator _____________________________
public class MyClassIncrementOperator {
public static void main(String[] args) {
int x = 5;
++x;
System.out.println(x);
}
}

-- Decrement Decreases the value of a variable by 1 --x

Try to run this code: This will produce an output:


//Decrement Operator _____________________________
public class MyClassDecrementOperator {
public static void main(String[] args) {
int x = 5;
--x;
System.out.println(x);
}
}

Java Assignment Operators (10 points)


Assignment operators are used to assign values to variables. In the example below, we use the
assignment operator (=) to assign the value 10 to a variable called x:

Example:
int x = 10;
Try to run this code: This will produce an output:
//Assignment Operators 1 10
public class
MyClassAssignemntOperators1 {
public static void main(String[] args) {
int x = 10;
System.out.println(x);
}
}

The addition assignment operator (+=) adds a Try to run this code:
value to a variable: // Assignment Operators 2
Example: public class
int x = 10; MyClassAssignemntOperators2{
x += 5; public static void main(String[] args) {

PANGASINAN STATE UNIVERSITY 3


Prepared by: Edilberto L. Caralos Jr. FM-AA-CIA-15 Rev. 0 30-March-2021

Study Guide in SIA 101 Systems Integration and Architecture

int x = 10;
x += 5;
System.out.println(x);
}
}

Operator Example Same As


= x=5 x=5

Try to run this code: This will produce an output:


// Simple assignment operator, Assigns values from _____________________________
right side operands to left side operand.
public class MyClassAssignmentOperator
{
public static void main(String[] args) {
int x = 5;
System.out.println(x);
}
}

+= x += 3 x=x+3

Try to run this code: This will produce an output:


// Add AND assignment operator, It adds right _____________________________
operand to the left operand and assign the result to
left operand.
public class
MyClassAddAndAssignmentOperator {
public static void main(String[] args) {
int x = 5;
x += 3; //same as x = x+3;
System.out.println(x);
}
}

-= x -= 3 x=x-3

Try to run this code: This will produce an output:


// Subtract AND assignment operator, It subtracts _____________________________
right operand from the left operand and assign the
result to left operand.
public class
MyClassSubtractAndAssignmentOperator {
public static void main(String[] args) {
int x = 5;
x -= 3; // same as x = x – 3;
System.out.println(x);
}
}

*= x *= 3 x=x*3

Try to run this code: This will produce an output:


// Multiply AND assignment operator, It multiplies _____________________________
right operand with the left operand and assign the
result to left operand.

PANGASINAN STATE UNIVERSITY 4


Prepared by: Edilberto L. Caralos Jr. FM-AA-CIA-15 Rev. 0 30-March-2021

Study Guide in SIA 101 Systems Integration and Architecture

public class
MyClassMultiplyAndAssignmentOperator
{
public static void main(String[] args) {
int x = 5;
x *= 3; // same as x = x * 3;
System.out.println(x);
}
}

/= x /= 3 x=x/3

Try to run this code: This will produce an output:


// Divide AND assignment operator, It divides left _____________________________
operand with the right operand and assign the
result to left operand.
public class
MyClassDivideAndAssignmentOperator
{
public static void main(String[] args) {
double x = 5;
x /= 3; // sames as x = x/3;
System.out.println(x);
}
}
%= x %= 3 x=x%3

Try to run this code: This will produce an output:


// Modulus AND assignment operator, It takes _____________________________
modulus using two operands and assign the result
to left operand.
public class
MyClassModuloAndAssignmentOperator
{
public static void main(String[] args) {
int x = 5;
x %= 3;
System.out.println(x);
}
}

&= x &= 3 x=x&3

Try to run this code: This will produce an output:


// Bitwise AND Assignment Operator _____________________________
public class
MyClassBitwiseAndAssignmentOperator
{
public static void main(String[] args) {
int x = 5;
x &= 3;
System.out.println(x);
}
}

PANGASINAN STATE UNIVERSITY 5


Prepared by: Edilberto L. Caralos Jr. FM-AA-CIA-15 Rev. 0 30-March-2021

Study Guide in SIA 101 Systems Integration and Architecture

|= x |= 3 x=x|3

Try to run this code: This will produce an output:


// Bitwise inclusive OR assignment operator. _____________________________
public class
MyClassBitwiseInclusiveOrlAssignmentOpera
tor {
public static void main(String[] args) {
int x = 5;
x &= 3; // same as x = x & 3;
System.out.println(x);
}
}

^= x ^= 3 x=x^3

Try to run this code: This will produce an output:


// Bitwise exclusive OR and assignment operator _____________________________
public class
MyClassBitwiseExclusiveOrAssignmentOperat
or {
public static void main(String[] args) {
int x = 5;
x ^= 3; // same as x = x ^3;
System.out.println(x);
}
}

>>= x >>= 3 x = x >> 3

Try to run this code: This will produce an output:


// Right shift AND assignment operator. _____________________________
public class
MyClassRightShiftAssignmentOperator {
public static void main(String[] args) {
int x = 5;
x >>= 3; // sames as x = x >> 3;
System.out.println(x);
}
}

<<= x <<= 3 x = x << 3

Try to run this code: This will produce an output:


// Left shift AND assignment operator. _____________________________
public class
MyClassLeftShiftAndAssignmentOperator {
public static void main(String[] args) {
int x = 5;
x <<= 3;
System.out.println(x);
}
}

PANGASINAN STATE UNIVERSITY 6


Prepared by: Edilberto L. Caralos Jr. FM-AA-CIA-15 Rev. 0 30-March-2021

Study Guide in SIA 101 Systems Integration and Architecture

For easy tracking of your file/s strictly follow the correct filename format given below.
Filename: Deadline:
LastnameFirstNameMI_Assignement1 October 08, 2021 till 5:00 PM
e.g. DelacruzJuanL_Assignment1
IMPORTANT! Late submission of paper/s will not be accepted, regardless of the reason(s).

PANGASINAN STATE UNIVERSITY 7


Prepared by: Edilberto L. Caralos Jr. FM-AA-CIA-15 Rev. 0 30-March-2021

Study Guide in SIA 101 Systems Integration and Architecture

Additional Information:
IMPORTANT! Read carefully with understanding and strictly follow the instructions given below.

1. All home-based activities/assessments except quizzes (i.e. assignments, activities, exercises and etc.)
shall be submitted to the FB Messenger (Group Chat) and MS Teams account.
FB Messenger (GC) -> First Priority
1.1 Using Facebook Messenger on a Desktop, Laptop, Phone or Tablet.
1.1.1 Open Facebook.
1.1.2 Tap ☰.
1.1.3 Tap Groups.
1.1.4 Tap Files.
1.1.5 Tap +.
MS Teams -> Second Priority
1.2 Go to General Posts:

Click new conversation button


Each submission can only have one "new conversation".

Click the attached file


Note: don’t add message/s your filename attachment is enough.
1.2.1 Filename for example using camel uppercase:
1.2.1.1 LastnameFirstNameMI_Activity1
1.2.1.2 LastnameFirstNameMI_Exercise1
1.2.1.3 LastnameFirstNameMI_Seatwork1
1.2.1.4 LastnameFirstNameMI_Assignment1
1.2.1.5 LastnameFirstNameMI_MiniProject1 and etc…
1.3.1 If you don't want anyone to see your work/s, put a password on it and send it to your instructor
privately. For those students whose job is to copy and paste, ask yourself, "Copy, paste, steal?
Is it plagiarism theft or simply laziness? Either way..."
1.3.2 Don’t forget to use the same password for the next submission.
1.3.2.1 Set password in (e.g. Word 2013) documents.

PANGASINAN STATE UNIVERSITY 8


Prepared by: Edilberto L. Caralos Jr. FM-AA-CIA-15 Rev. 0 30-March-2021

Study Guide in SIA 101 Systems Integration and Architecture

1.3.2.1.1 Open the Word document of which you want to set the password.

1.3.2.2 Click the File Tab and then click the Info option and then the Protect Document button
that shows a list of options to be selected.

1.3.2.3 Now click the Encrypt with Password option simply by clicking on it. That will display
an Encrypt Document dialog box asking for a password to encrypt the document. This
dialog box will appear twice to reenter the same password. And every time click the OK
button after entering the password

Note: If a document “does not have a password”, the overall score will be deducted
by five (5) points.
2. If ever all documents taken as photos shall be renamed bearing your name and the activity (e.g.
LastnameFirstnameMI_Activity1) for purposes of monitoring of submission and on-time passing.
See number 1.2.1 also as guide. Compressed the file/s (e.g. images or photos taken in your screenshots)
using .zip or .rar format before sending it to you FB Messenger (Group Chat) and MS Teams account.
2.1 How to compress your file and put password on it?

PANGASINAN STATE UNIVERSITY 9


Prepared by: Edilberto L. Caralos Jr. FM-AA-CIA-15 Rev. 0 30-March-2021

Study Guide in SIA 101 Systems Integration and Architecture

2.1.1 First, make shore that WinRAR or WinZip software installed in your device. You can download
the software’s in the links below:
2.1.1.1 https://www.rarlab.com/ or https://www.win-rar.com/ or https://www.winzip.com
2.1.1.2 Click here for detailed instructions on installing WinRAR.
2.1.1.3 Right Click on the files you want to compress and click on "Add to archive".

2.1.1.3.1 Open the WinRAR window and then browse for the files you want to Select
all the files and then click the "Add" button.
2.1.1.3.2 Select all of the files you want to archive in Windows. Right-click on your
selection and choose "Add to archive".
2.1.1.4 Give your archive a name. By default, it will be named after the folder the files were
originally in.

2.1.1.5 Click the Set password... button. This is located in the General tab of the "Archive
name and parameters" window that appears when creating a new archive.

PANGASINAN STATE UNIVERSITY 10


Prepared by: Edilberto L. Caralos Jr. FM-AA-CIA-15 Rev. 0 30-March-2021

Study Guide in SIA 101 Systems Integration and Architecture

2.1.1.6 Enter in your password. Enter it a second time to confirm it. You can check the
"Show password" box to see the characters as you type them.

2.1.1.7 Check the "Encrypt file names" box. This will ensure that no one can see the names
of the files contained in the RAR file until after they have successfully entered the
password.

PANGASINAN STATE UNIVERSITY 11


Prepared by: Edilberto L. Caralos Jr. FM-AA-CIA-15 Rev. 0 30-March-2021

Study Guide in SIA 101 Systems Integration and Architecture

2.1.1.8 Click OK to save your password. Click OK in the "Archive name and parameters"
window to create your new RAR file.

2.1.1.9 Test it out. After the RAR file is created, you can double-click it to test it out. When
you try to extract it, you will be prompted for the password you created.

PANGASINAN STATE UNIVERSITY 12


Prepared by: Edilberto L. Caralos Jr. FM-AA-CIA-15 Rev. 0 30-March-2021

Study Guide in SIA 101 Systems Integration and Architecture

3. If ever FB Messenger will reject your .rar or .zip file format alternative is to upload it to the free host file
serves such as: google drive or mediafire then share/post the link in the fb messenger group chat.
4. (Optional) Add “watermark” (sample format: DelaCruzJuanT_8-12-2021) inside your document.
4.1 How to insert a watermark in Microsoft Word (2007-current)?
4.1.1 On the Design tab, select Watermark.
4.1.2 In the Insert Watermark dialog, select Text and either type your own watermark text or select
one, like DRAFT, from the list. Then, customize the watermark by setting the font, layout, size,
colors, and orientation.
4.1.3 Select OK.

5. Congratulations!

PANGASINAN STATE UNIVERSITY 13

You might also like