Skip to content

Commit

Permalink
Create Simple Calculator in JAVA
Browse files Browse the repository at this point in the history
  • Loading branch information
goriblok1235 authored Oct 4, 2023
1 parent 8bf083a commit 61a2f75
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Simple Calculator in JAVA
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import java.util.*;
public class SimpleCalculator{
public static double add(double x, double y){
return x+y;
}
public static double subtract(double x, double y){
return x-y;
}
public static double mul(double x, double y){
return x*y;
}
public static double div(double x, double y){
return x/y;
}
public static double mod(double x, double y){
return x%y;
}
public static void main(String[] args) {
System.out.println("Simple Calculator:");
Scanner ob = new Scanner(System.in);
System.out.println("Enter first number: ");
double a = ob.nextDouble();
System.out.println("Enter second number: ");
double b = ob.nextDouble();

System.out.println("Addition of "+a+" and "+b+" is "+ add(a,b));
System.out.println("Subtraction of "+a+" and "+b+" is "+ subtract(a,b));
System.out.println("Multiplication of "+a+" and "+b+" is "+ mul(a,b));
System.out.println("Division of "+a+" and "+b+" is "+ div(a,b));
System.out.println("Mod of "+a+" and " +b+ " is "+mod(a,b));
ob.close();
}
}

0 comments on commit 61a2f75

Please sign in to comment.