Watch more such videos in below playlist: Java Tutorial: ru-vid.com/group/PLhyraTKIsw5_WemVMvshNm-0aC7zfISCO Java Programs: ru-vid.com/group/PLhyraTKIsw59nQJKvZTKmNK2aMxHwvLOa
Write a program for calculators in java which performs addition, subtraction, multiplication and division of any two numbers. Take user input using Scanner class and print the results of every calculation. do it
We can return the value of result since it is declared under main function.. we just needed to print result so it was printed within main, but you can return it as well if using another function for switch case
you can ask the user to provide input as one of these 4 operators as a string, and based on the operator and other 2 numbers, the calculations can be done
35/45 gives us result as 0.77 usually but in the Java code we are taking both these numbers as integers and that's why the result of division operation is also integer in this case - 0.77 is taken as 0 in the result.. Change the data type to double for both the inputs taken and you'll get the result as 0.77 Hope this helps 👍