+ 3

# Can someone please share me a code to create a calculator

25th Mar 2017, 9:18 PM
Hommiez 20
+ 14
//[ A Simple Calculator for You ] import java.util.Scanner; public class Calculator { public static void main(String[] args) { Scanner input = new Scanner(System.in); Maths Maths = new Maths(); double answer = 0; double inputA, inputB; char operator; boolean done = false; while (done == false) { System.out.print("Please enter your sum: "); inputA = input.nextDouble(); operator = input.next().charAt(0); inputB = input.nextDouble(); switch (operator) { case '+': answer = Maths.add(inputA, inputB); break; case '-': answer = Maths.subtract(inputA, inputB); break; case '*': answer = Maths.multiply(inputA, inputB); break; case '/': answer = Maths.divide(inputA, inputB); break; case '^': answer = Maths.power(inputA, inputB); break; } System.out.println(answer); } [The code isn't made by me, thanks to @Mayank who made this code!]
26th Mar 2017, 12:57 PM
Harshit Gupta
+ 10
wow.
26th Mar 2017, 1:01 PM
devbyemil
+ 10
XD
26th Mar 2017, 1:01 PM
devbyemil
+ 10
Next time you need a code, please search the uploaded codes on sololearn for it before you ask one! [Not necessarily, but this will save the time]
26th Mar 2017, 1:04 PM
Harshit Gupta
+ 7
I would but I've only made one in c++ and Python as I do not know java
26th Mar 2017, 10:32 AM
NightX
+ 1
thanks to y'all that answered my Q
26th Mar 2017, 3:57 PM
Hommiez 20
0
simplest code to create a calculator would be mad - calculator - algebra - etc... well something similar to this concept...
4th Apr 2017, 7:46 PM
katharine