Basic Calculator in java

Learn how to Build a Basic Calculator in java

import java.util.Scanner;

public class Demo {
public static void main(String args[]){
Scanner cal = new Scanner(System.in);

double first, second, sum, sub, mul, div, mod;

System.out.println(“Enter first number”);
first = cal.nextDouble();

System.out.println(“Enter second number”);
second = cal.nextDouble();

sum = first + second;
sub = first – second;
mul = first * second;
div = first / second;
mod = first % second;

System.out.println(“Sum is ” + sum);
System.out.println(“Sub is ” + sub);
System.out.println(“Mul is ” + mul);
System.out.println(“Div is ” + div);
System.out.println(“Mod is ” + mod);
}
}

 

Share

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.