I am trying to program a simple calculator program.But the problem is that when the user finishes his calculation, the program terminates. So I tried to make it in such a way that after you finish a calculation, the program asks you that if you want the program to terminate or not. But now I have no idea how to repeat the calculator program again infinitely.
My code (it is incomplete):
import java.util.Scanner ;
public class NewSrc
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter first number.... ");
double x = sc.nextDouble();
System.out.println("Enter next number....");
double y = sc.nextDouble();
double z = x*y;
System.out.println("processing answer ....");
System.out.println("The answer is :- " + z );
System.out.println("Do you want to continue ?Answer with either Yes or No ");
String Agree = "Yes";
String Disagree = "No";
String Continue = sc.nextLine();
if (Continue == Agree)
{
//How to restart it?
}
}
}