Project Detail: Create calculator application which accepts two numbers from user and perform addition, subtraction, multiplication and division on given numbers.
                                     ————————–  *  —————————–
package calculator;
public class Calculation {
      int result;
      //Method for addition
      public int add(int num1, int num2){
            result = num1+num2;
            return result;
      //Method for subtraction
      public int substract(int num1, int num2){
            result = num1num2;
            return result;
      //Method for multiplication
      public int multiply(int num1, int num2){
            result = num1*num2;
            return result;
      //Method for division
      public float divide(int num1, int num2){
            result = num1/num2;
            return result;
package calculator;
public class CalculatorVO {
      private int firstNumber;
      private int secondNumber;
      public intgetFirstNumber() {
            return firstNumber;
      public void setFirstNumber(int firstNumber) {
            this.firstNumber = firstNumber;
      public intgetSecondNumber() {
            return secondNumber;
      public voidsetSecondNumber(int secondNumber) {
            this.secondNumber = secondNumber;
package calculator;
public class MainClass {
      public static void main(String[] args) {
            CalculatorVO calVO = new CalculatorVO();
            //Input can be taken from user
            Calculation cal = new Calculation();
            int addResult = cal.add(calVO.getFirstNumber(), calVO.getSecondNumber());
            System.out.println(“Addition Result =”+addResult);
            int subResult = cal.substract(calVO.getFirstNumber(), calVO.getSecondNumber());
            System.out.println(“Subtraction Result =”+subResult);
            int mulResult = cal.multiply(calVO.getFirstNumber(), calVO.getSecondNumber());
            System.out.println(“Multiplication Result =”+mulResult);
            float divResult = cal.divide(calVO.getFirstNumber(), calVO.getSecondNumber());
            System.out.println(“Division Result =”+divResult);

Addition Result =111
Subtraction Result =89
Multiplication Result =1100
Division Result =9.0

Source link

Calculator Application in java

Leave a Reply

Your email address will not be published. Required fields are marked *