I decided to try to make a very simple calculator in Java. I copied someone else's code and I'm trying to add my own ideas to it.
Now the question is, how do I get it to re-ask the question and clear the previous answers?
Here's my code:
package calculator;
import java.util.*;
public class Calculator {
public static void main(String[] args) {
double num1;
double num2;
String operation;
boolean run = true;
while(run) {
Scanner input = new Scanner(System.in);
System.out.println("Please enter the first number");
num1 = input.nextInt();
System.out.println("Please enter the second number");
num2 = input.nextInt();
Scanner op = new Scanner(System.in);
System.out.println("Please enter an operation");
operation = op.next();
if (operation.equals("+"))
{
System.out.println("Your answer is " + (num1 + num2));
}
if (operation.equals("-"))
{
System.out.println("Your answer is " + (num1 - num2));
}
if (operation.equals("*"))
{
System.out.println("Your answer is " + (num1 * num2));
}
if (operation.equals("/"))
{
System.out.println("Your answer is " + (num1 / num2));
}
}
}
}