Created
January 18, 2018 16:53
-
-
Save arif98741/9ebdded4daf7fd63adaa3ea44466d23d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package calculation; | |
public class Cal { | |
private int num1 = 0; | |
private int num2 = 0; | |
public Cal(int a, int b) { | |
this.num1 = a; | |
this.num2 = b; | |
} | |
public int Addition() { | |
int result = this.num1 + this.num2; | |
return result; | |
} | |
public int Subtraction() { | |
int result = this.num1 - this.num2; | |
return result; | |
} | |
public int Multiplication() { | |
int result = this.num1 * this.num2; | |
return result; | |
} | |
public int Division() { | |
int result = this.num1 / this.num2; | |
return result; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package calculation; | |
public class Calculation { | |
public static void main(String[] args) { | |
Cal c1 = new Cal(5, 10); | |
Cal c2 = new Cal(25, 30); | |
//for first 5,10 | |
System.out.println("Addition for first object is " + c1.Addition()); | |
System.out.println("Subtraction for first object is " + c1.Subtraction()); | |
System.out.println("Multiplication for first object is " + c1.Multiplication()); | |
System.out.println("Division for first object is " + c1.Division()); | |
System.out.println(); | |
System.out.println("Addition for second object is " + c2.Addition()); | |
System.out.println("Subtraction for second object is " + c2.Subtraction()); | |
System.out.println("Multiplication for second object is " + c2.Multiplication()); | |
System.out.println("Division for second object is " + c2.Division()); | |
System.out.println(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment