java - Simple Command Line calculator -
i have written code command-line calculator in java can't understand errors not allowing compile
public class calculator{ public static void main(string[] args){ int numone = args[0]; int numtwo = args[1]; add(numone, numtwo) { result = numone + numtwo; system.out.println("{numone} + {numtwo} = {result}"); } subtract(numone, numtwo) { result = numone - numtwo; system.out.println("{numone} - {numtwo} = {result}"); } multiply(numone, numtwo) { result = numone * numtwo; system.out.println("{numone} * {numtwo} = {result}"); } divide(numone, numtwo) { result = numone / numtwo; system.out.println("{numone} / {numtwo} = {result}"); } } }
the translation java of code is:
public class calculator { public static void add(int numone, int numtwo) { int result = numone + numtwo; system.out.println(numone + " + " + numtwo + " = " + result); } public static void subtract(int numone, int numtwo) { int result = numone - numtwo; system.out.println(numone + " - " + numtwo + " = " + result); } public static void multiply(int numone, int numtwo) { int result = numone * numtwo; system.out.println(numone + " * " + numtwo + " = " + result); } public static void divide(int numone, int numtwo) { int result = numone / numtwo; system.out.println(numone + " / " + numtwo + " = " + result); } public static void main(string[] args) { int numone = integer.parseint(args[0]); int numtwo = integer.parseint(args[1]); add(numone, numtwo); subtract(numone, numtwo); multiply(numone, numtwo); divide(numone, numtwo); } }
Comments
Post a Comment