Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Java/calculator
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import java.util.Scanner;
import java.util.*;

public class Calculator {

Expand All @@ -11,10 +11,10 @@ public class Calculator {
double first = reader.nextDouble();
double second = reader.nextDouble();

System.out.print("Enter an operator (+, -, *, /): ");
System.out.print("Enter an operator (+, -, *, /,^): ");
char operator = reader.next().charAt(0);

double result;
double result=0;

switch(operator)
{
Expand All @@ -33,6 +33,10 @@ public class Calculator {
case '/':
result = first / second;
break;
case '^':
result = Math.pow(first,second);
break;


// operator doesn't match any case constant (+, -, *, /)
default:
Expand Down