Page 32 - CTS - CSA TP - Volume 2
P. 32
COMPUTER SOFTWARE APPLICATION - CITS
TASK 4: Java Arithmetic Operator Example
public class OperatorExample4{
public static void main(String args[]){
int a=10;
int b=5;
System.out.println(a+b);//15
System.out.println(a-b);//5
System.out.println(a*b);//50
System.out.println(a/b);//2
System.out.println(a%b);//0
}}
Output:
TASK 5: Java Arithmetic Operator Example: Expression
public class OperatorExample5{
public static void main(String args[]){
System.out.println(10*10/5+3-1*4/2);
}}
Explanation:
1 Arithmetic Expression:
• The program consists of a single arithmetic expression within the System.out.println statement.
2 Order of Operations (BODMAS/BIDMAS):
• The arithmetic expression follows the order of operations (also known as BODMAS or BIDMAS), which
stands for:
• Brackets or Parentheses
• Orders (i.e., powers and square roots, etc.)
• Division and Multiplication (from left to right)
• Addition and Subtraction (from left to right)
17
CITS : IT & ITES - Computer Software Application - Exercise 82 CITS : IT & ITES - Computer Software Application - Exercise 82