FAQ: Debugging - Debugging Techniques

bash is the terminal , where you can compile or run the programs,.
to compile you write in bash : javac “nameOfTheProgram”.java
to run a program : java “nameOfTheProgramm”

compiling is just a process where the terminal will take all the programing you did in java and sort of translate it to binary so the computer will follow the rules and indications you wrote. that’s why compiling only catches “grammar” ans syntax errors.


What exactly are the units involved in the area result after the calculations in the functions are done and return what ever value is stored in the ‘int A’ variable ?

For example, I choose 1 for triangle, enter 5 for base and 9 for height, the area of that triangle is 22.
22 what ?

It depends on the units for the base and the height. You can use any unit of measurement for distance/length (e.g. inches, cm, feet, metres but not pounds, mL, etc.).

  • For example, a triangle with a base of 3 inches and a height of 4 inches has an area of 6 square inches.
  • Or, a triangle with a base of 4 cm and a height of 6 cm has an area of 12 square centimetres.

You can modify your code to ask the user to input the base and height in inches, then modify the print statement to display the area in square inches (or cm and square cm, for example).

Would the same thing apply to rectangle and circle ?

The code doesn’t take the input and process it in any specific way for a specific unit of measurement, be it square cm or square inches.

Yes, the area of a rectangle or circle would be the square unit of whatever unit was inputted as the length and width for the rectangle or the diameter/radius for the circle.

You are correct, but also note that no matter which unit you choose, the equation to calculate the area remains the same.

Concepts discussed in this lesson, on this page 7 haven’t been covered in previous lessons. Especially receiving inputs! I would love a lesson on these!

I am having trouble being able to make the necessary modifications and re-test the changes. It keeps running the original code?


Completed project Debugging Techniques Area calculator

  • Area for triangle working
  • Area for Rectangle working
  • Area for circle working


I’m not sure if the lesson has been updated, but I found 2 logic errors while testing the math in bash. my code had the usual *2 instead of /2 in the triangle method, but it also had

}else if (shape == 2) {

on lines 31 and 32, so if I input shape 3 in bash, I would just get prompted to select a shape again. had to change it to:

} else if (shape == 3) {

1 Like

Welcome to the forums!

Nice catch! I’ve submitted a bug report; for any future bugs you may find, you can create a topic in the Bug Reporting category.

1 Like

Great catch. Fixed!

Feel free to check it out (might need to refresh) and see if it’s good to go.

Yep, it’s showing shape == 3 now. :slight_smile:

1 Like