import java.util.Scanner; public class Calculate { static Scanner in = new Scanner(System.in); public static void main(String [] args) { String sign; int num1; int num2; int num3; int ans; System.out.print("Enter your Calculations => \n"); sign = in.nextLine(); if(args.Length == 3) { num1 = Integer.parseInt(args[0]); sign = (args [1].equal("1")); num2 = Integer.parseInt(args[2]); num3 = Integer.parseInt(args[3]); ans = num1 + num2; ans = num1 - num2; ans = num1 / num2; System.out.println("Answer = "+ ans); } else if(args[1].equal("+")) { ans = num1 + num2; System.out.println("num1 "+ "num2 " = ans); } else if(args[2].equal("-")) { ans = num1 - num2; System.out.println("num1 "- "num2 "= ans); } else if(args[3].equal("/")) { ans = num1 / num2; System.out.println("num1 "/ "num "= ans); } else if("Do it again => Calculate arg1, arg2, arg3"); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)