From the course: Learning Java 11

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Challenge: Find the errors

Challenge: Find the errors - Java Tutorial

From the course: Learning Java 11

Start my 1-month free trial

Challenge: Find the errors

(upbeat music) - [Instructor] It's time to find some errors in a program with this coding challenge. Be sure to use the tools you've learned about so far, including print statements, break points, and the debugger. For this challenge, you will find and fix three errors hidden in a program that calculates the area of a triangle. The program will ask the user for the base of the triangle and the height of the triangle. Then the program will calculate the area of the triangle using the formula, base times height divided by two. Once the area of the triangle is found, the program will output the area to the user. Neither the base nor the height of the triangle should be less than or equal to zero. Let's check out the current program. In the main function, we should calculate the area of a triangle. Right now, the program doesn't work and there are three errors. Check out the exercise files to get access to this program. Good luck!

Contents