Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- //this is a calculator that computes basic operations of math
- //
- import java.util.Scanner;
- public class Calculator {
- static Scanner sc = new Scanner(System.in);
- public static void main(String [] args) {
- //create variables
- double a;
- double b;
- //input
- System.out.print("Enter a : ");
- a = sc.nextDouble();
- System.out.print("Enter b : ");
- b = sc.nextDouble();
- //basic operations
- double add = a+b;
- double subtract = a-b;
- double multiply = a*b;
- double divide = a/b;
- //outputs
- System.out.println("Sum : " + add);
- System.out.println("Difference : " + subtract);
- System.out.println("Product : " + multiply);
- System.out.println("Quotient : " + divide);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement