Create a class SimpleCalculator that has functionality of addition, substraction division, multiplication, square and squareroot.

class Calculator
  {
   public void calc()
    {
    int add, sub, mul, a, b, n,sqr,m;
    double div;
    a=Integer.parseInt(System.console().readLine("enter the first no.  :"));
    b=Integer.parseInt(System.console().readLine("enter the second no. :"));
    add=a+b;
    System.out.println("addition of two no.      ="+add);
    sub=a-b;
    System.out.println("substraction of two no.  ="+sub);
    mul=a*b;
    System.out.println("multiplecation of two no.="+mul);
    div=(double)a/b;
    System.out.println("division of two no.      ="+div);
    n=Integer.parseInt(System.console().readLine("enter the no. jiska square niklna hai  :"));
    sqr=n*n;
    System.out.println("square of the no="+sqr);
    m=Integer.parseInt(System.console().readLine("enter the no. jiska square niklna hai  :"));
    double sqtroot=Math.sqrt(m);
    System.out.println("squareroot of the no="+sqtroot);
   }
 
public static void main(String args[])
    {
      Calculator s=new Calculator();
      s.calc();
    
      
    }
 }


 

No comments:

Post a Comment