How to tackle a homework prgram that reads three sides for a triangle and computes the area if the input is valid?

前端 未结 3 359
半阙折子戏
半阙折子戏 2021-01-29 07:06

Here is my task:

Create a class named MyTriangle that contains the following two methods:

/** Return true if the sum of any two sides is *         


        
3条回答
  •  有刺的猬
    2021-01-29 08:02

    You are just declaring a variable called "isValid" and setting it equal to true. You need to instead calculate the length of the sides before you check if the input is valid. Then you call the isValid function by calling

    isValid(side1, side2, side3);

提交回复
热议问题