I need to know how to make my code repeat if the user types in NEW at the end of the program. Anybody know how? Please it is for a class
Code:
import java.util.Scanner;
public class Calc {
static Scanner trap = new Scanner (System.in);
public static void main( String args []) throws InterruptedException
{
//Variables: Base 1, Base 2, Height //
double B1;
double B2;
double height;
System.out.println("What is the length of the top of your trapezoid?");
B1 = trap.nextDouble();
System.out.println("What is the length of the bottom of your trapezoid? ");
B2 = trap.nextDouble();
System.out.println("What is the height of your trapezoid?");
height = trap.nextDouble();
double b3 = B1 + B2;
double almArea = b3 / 2;
double area = almArea * height;
System.out.println("The area of your trapezoid is:" + area);
Thread.sleep(2000);
System.out.println("Would you like to use me again? Type NEW if yes.");
}
}