0% found this document useful (0 votes)
89 views

Java 1 Arithmetic Operators

The document describes arithmetic operators in Java. It lists common operators like addition, subtraction, multiplication, and division. It also describes the modulus operator, increment operator, and decrement operator. The increment and decrement operators can be pre-increment, post-increment, pre-decrement, and post-decrement depending on if the variable is incremented/decremented before or after the statement. Examples are provided to demonstrate the different arithmetic operators.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views

Java 1 Arithmetic Operators

The document describes arithmetic operators in Java. It lists common operators like addition, subtraction, multiplication, and division. It also describes the modulus operator, increment operator, and decrement operator. The increment and decrement operators can be pre-increment, post-increment, pre-decrement, and post-decrement depending on if the variable is incremented/decremented before or after the statement. Examples are provided to demonstrate the different arithmetic operators.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

ARITHMETIC OPERATORS IN JAVA

Operator Description
Addition operator
+
(also used for String concatenation)
­ Subtraction operator
* Multiplication operator
/ Division operator
% Modulus operator (gets the remainder)
Increment Operator-
++ Pre-Increment- a variable will be added by 1 before current statement is executed
Post Increment- a variable will be added by 1 after the current statement is executed
Decrement Operator-
­­ Pre-Decrement- a variable will be decreased by 1 before current statement is executed
Post-Decrement- a variable will be decreased by 1 after the current statement is executed
Example:

Name: ________________________________________ Class Sched: ________________

IT112 Jay Anthony R. Nuñez


Fundamentals in Programming Instructor
Activity #2 – Arithmetic Operations
Self-Paced Learning
Try and test the following codes/statements provided for each item. Explain what you have noticed with the
process or output after each example. If error occurs, determine and explain the cause/s.
# CODE / STATEMENTS CONCLUSION

int num1=1, num2=2;


int sum=num1+num2;
1 System.out.println("Result 1:"+sum+5);
System.out.println("Result 2:"+(sum+5));
System.out.println("Result 3:"+sum);

int num1=1;
double num2=2;
2 double quotient=num1/num2;
System.out.print("Result 1:"+quotient);

int num1=1;
int num2=2;
int quotient1=num1/num2;
3 double quotient2=num1/num2;
System.out.println("Result 1:"+quotient1);
System.out.println("Result 2:"+quotient2);

double num1=1;
double num2=2;
4 int quotient=num1/num2;
System.out.print("Result 1:"+quotient);

int num=5;
num++;
System.out.println("Result 1:"+num);
--num;
System.out.println("Result 2:"+num);
5
num=num+1;
System.out.print("Result 3:"+num);
num+1;
System.out.print("Result 4:"+num);

*Pass this activity sheet only.

IT112 Jay Anthony R. Nuñez


Fundamentals in Programming Instructor

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy