Write a java program for calculator consist of 4 methods, to perform
- addition of 4 numbers.
- substraction of 5 numbers.
- multiplication of 3 numbers.
- division of 2 numbers.
- class Calculator
- {
- public static void add( int a, int b, int c, int d )
- {
- int e =a+b+c+d;
- System.out.println(e);
- }
- public static void sub( int a, int b, int c, int d,int e )
- {
- int f =a-b-c-d-e;
- System.out.println(f);
- }
- public static void multiply( int a, int b, int c )
- {
- int d =a*b*c;
- System.out.println(d);
- }
- public static void div( int a, int b )
- {
- int e =a/b;
- System.out.println(e);
- }
- public static void main(String [] args)
- {
- add(1,2,3,4);
- sub(1,2,3,4,5);
- multiply(2,3,5);
- div(4,2);
- }
- }
Output:
10
-13
-13
30
2
0 Comments