Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Calculator {
- public static void main(String[]args)
- {
- Numeric another=new Numeric();
- Scanner keyboard=new Scanner(System.in);
- String a , b, op;
- double c=0;
- do
- {
- System.out.print("> ");
- a=keyboard.next();
- op=keyboard.next();
- if(Numeric.isNumeric(a))
- {
- if(Numeric.isInteger(a))
- {
- b=keyboard.next();
- int B=Integer.parseInt(b);
- int A=Integer.parseInt(a);
- if(op.equals("+"))
- {
- c=B+A;
- }
- if(op.equals("-"))
- {
- c=B-A;
- }
- //etc
- }
- else if(Numeric.isDouble(a))
- {
- }
- }
- else
- {
- if(a.equals("sin"))
- {
- double OP=Double.parseDouble(op);
- c=Math.sin(OP);
- }
- else if(a.equals("cos"))
- {
- double OP=Double.parseDouble(op);
- c=Math.cos(OP);
- }
- //etc
- }
- System.out.println(c);
- }
- while(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment