Hi I seem to need help here again. I am not sure how to use the try-catch method to make sure that the user inputs only numbers, and if the user inputs anything else, it will give an error and prompt the user to enter the numbers again.
here is the part of the code where I ask for all of the numbers.
thanks.
public static void main(String[] args) { Scanner sc = new Scanner(System.in); int count = 1; double s1 = 0.0, s2 = 0.0, s3 = 0.0; double base = 0.0, height = 0.0; System.out.println("Welcome to the Triangle program"); while(count >= 1){ System.out.println("Enter side 1: "); s1 = sc.nextDouble(); System.out.println("Enter side 2: "); s2 = sc.nextDouble(); System.out.println("Enter side 3: "); s3 = sc.nextDouble(); System.out.println("Enter the base: "); base = sc.nextDouble(); System.out.println("Enter the height: "); height = sc.nextDouble(); }