Fixing a bug

Report a typo

Create a file Triangle_area.java and copy the following code into it:

import java.lang.Math;
import java.lang.Integer;

public class Triangle_area {
    public static void main(String[] args) {
        int a = 15;
        int b = 7;
        int c = 10;
        int p1 = (a + b + c) / 2;
        double s = Math.sqrt(p1 * ((p1 - a * p1 - b) * (p1 - c)));
        System.out.println(s);
    }
}

This program calculates the area of a triangle on three sides, but the result is NaN. On which line should you put a breakpoint to find the error?

Select one option from the list
___

Create a free account to access the full topic