JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*This is a calculator.
Enter any number from 1 to 9.
For choice 1 to 4 & 7, Enter 2 more numbers.
For other choices, Enter only 1 more number.
Enter yes to continue the program and any other input to end.
Enjoy this Program.*/
//Programmed by @AmritJ.
import java.util.*;
import java.math.*;
public class Calculator
{
public static void main(String args[])
{
int a;
double b,c,d;
String x="yes";
Scanner in= new Scanner(System.in);
while(x.equalsIgnoreCase("yes"))
{
System.out.println("Enter 1 for addition of 2 numbers.");
System.out.println("Enter 2 for subtraction of 2 numbers");
System.out.println("Enter 3 for multiplication of 2 numbers");
System.out.println("Enter 4 to divide 2 numbers");
System.out.println("Enter 5 to find the square of a number");
System.out.println("Enter 6 to find the cube of a number");
System.out.println("Enter 7 to raise a number to a power.");
System.out.println("Enter 8 to find the square root of a number");
System.out.println("Enter 9 to find the cube root of a number");
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run