Professional Documents
Culture Documents
AARON - S - GESMUNDO - ActivityNo. 2 (Atcitty Quiz)
AARON - S - GESMUNDO - ActivityNo. 2 (Atcitty Quiz)
Gesmundo
Answer
I write sample code in each java operator and apply the multiple inheritance.
The blue line represent a new class for each java operator and my student information.
INPUT
package JAVAOPERATORS;
//I use class MAINCLASS to run all the methods that I created
// object
// I use only class Modulus to access all method in multiple class using inheritance.
System.out.println("Output of Arithmetic Operators");
Modulus equal = new Modulus();
equal.addition(10, 20, 30);//assign value
equal.subtraction(10, 20);//assign value
equal.division(10, 20);//assign value
equal.multiplication(5,5);//assign value
equal.increment(5);//assign value
equal.decrement(10);//assign value
equal.modulus(3, 100);//assign value
//I use only class OROPERATOR to access all method in multiple class using
inheritance.
System.out.println("\n\nOutput of Logical Operators");
OROPERATOR and = new OROPERATOR ();
and.andoperator(30, 50);
and.oroperator(30, 50);
//I use only class R_Lessthanorequalt to access all method in multiple class
using inheritance.
System.out.println( "\n\nOutput of Relational Operator");
R_Lessthanorequalto answer= new R_Lessthanorequalto();
answer.equal(10, 10);//assign value
answer.notequal(20, 10);//assign value
Aaron S. Gesmundo
answer.greaterthan(10,20);//assign value
answer.lessthan(2,8);//assign value
answer.greaterthanorequalto (14, 19);//assign value
answer.lessthanorequalto(30, 40);//assign value
System.out.println("\n\nOutput of UnaryOperator");
UnaryOperator result = new UnaryOperator();
result.answer();
//I use only class S_rightshift to access all method in multiple class using
inheritance.
System.out.println("\n\nOutput of Shift Operator");
S_rightshift shift = new S_rightshift ();
shift.leftshift(40, 2);//assign value
shift.rightshift(60, 5);//assign value
System.out.println("\n\nOutput of TernaryOperator");
TernaryOperator total = new TernaryOperator();
total.result();
//I use only class A_multplier to access all method in multiple class using
inheritance.
System.out.println("\n\nAOutput of ssignmentOperator");
A_multplier totall = new A_multplier();
totall.additionalassignment();
totall.multiplicationassignment();
System.out.println("\n\nOutput of BitwiseOperator");
BitwiseOperator resultafter = new BitwiseOperator ();
resultafter.main(args);
}
}
package JAVAOPERATORS;
//Attribute
int sum;
}
}
//Attribute
int product;
//Attribute
int incre;
}
}
package JAVAOPERATORS;
//Logical operators are used to determine the logic between variables or values
//I created new class to compile two Logical Operator sample code
public class LogicalOperator {
// && operator will give true value if both the operands are true. Otherwise,
it will give false.
//main method
public void andoperator(int a, int b) {
Aaron S. Gesmundo
}
}
}
// OR || operator will give true value if any one of the operand is true. If
both are false then it will return false.
//main method
public void oroperator(int a, int b) {
//using if else statements to apply logical operator
if (a > 20 || b > 40) {
System.out.println("The statement is true");
}else {
System.out.println("The statement is false");
}
}
}
package JAVAOPERATORS;
package JAVAOPERATORS;
//I created new class to run a UnaryOperator sample code
// Unary Operator is used to represent the positive or negative value,
increment/decrement the value by 1
int x = 30;
package JAVAOPERATORS;
Aaron S. Gesmundo
//variable
int lshift;
//main method
public void leftshift(int x, int y) {
lshift = x<<y;
System.out.println(lshift);
}
}
class S_rightshift extends ShiftOperator {
//variable
int rshift;
//main method
public void rightshift(int x, int y) {
rshift = x>>y;
System.out.println(rshift);
}
package JAVAOPERATORS;
//Ternary operator i a condition that evaluates to either true or false, plus a value
that is returned if the condition is true and another value that is returned if the
condition is false.
//class
public class TernaryOperator {
//assign value
public void result(){
int x = 10;
int y = 20;
System.out.println(result );
}
}
Aaron S. Gesmundo
package JAVAOPERATORS;
//main method
public void additionalassignment() {
//assign value
int x = 1000;
int y = 200;
x += y;
System.out.println(x);
}
}
class A_multplier extends AssignmentOperator{
//main method
public void multiplicationassignment() {
//assign value
int x = 1000;
int y = 200;
x *= y;
System.out.println(x);
package JAVAOPERATORS;
// bitwise and
// 0101 & 0111=0101 = 5
Aaron S. Gesmundo
// bitwise or
// 0101 | 0111=0111 = 7
System.out.println("a|b = " + (a | b));
// bitwise xor
// 0101 ^ 0111=0010 = 2
System.out.println("a^b = " + (a ^ b));
// bitwise not
// ~0101=1010
// will give 2's complement of 1010 = -6
System.out.println("~a = " + ~a);
package JAVAOPERATORS;
//class
public class MYSTUDENTINFORMATION {
//variable
String name, course, subject, block, schedule;
//main method
public static void main (String []args) {
System.out.println("\nName: Aaron Gesmundo");
System.out.println("Course: BSCOMPUTERSCIENCE");
System.out.println("Subject: CS322 - Object Oriented Programming");
System.out.println("Block: Block B");
System.out.println("Schedule: TF - 4:00-6:00 / 7:00");
}
}
OUTPUT
Aaron S. Gesmundo
Output of UnaryOperator
30
32
32
30
Output of TernaryOperator
y is greater
AOutput of ssignmentOperator
1200
200000
Output of BitwiseOperator
a&b = 8
a|b = 10
a^b = 2
~a = -11
a= 8
Aaron S. Gesmundo
My Student Informtation