Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8672053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:06:20+00:00 2026-06-12T19:06:20+00:00

I am confused with the technical jargon that was involved in this question: Given

  • 0

I am confused with the technical jargon that was involved in this question:

Given three straight lines a, b & c. They will be able to form a
triangle provided that sum of any two lines is always greater than the
third line (i.e. a + b > c and b + c > a and a + c

b). Write a Java class Triangle with the following:

Attributes: length of the three sides of the triangle 
Behaviour:
  • Constructor that sets the length of the three sides to the values passed in. The constructor should throw an InvalidValueException
    object when the values are not able to form a triangle.

    • findArea() method to calculate the area of the Triangle object using the formula area = a +b+c

The code that I came up with is this:

package question3_test;

import java.awt.event.*;
import java.math.*;

public class Triangle_getvalues 
{


    private int side1, side2, side3;
    private double area;
    private String message;


    public  int getSide1()
    {
        return side1;
    }

    public void setSide1(int s1)
    {
        side1 = s1;
    }

    public  int getSide2()
    {
        return side2;
    }

    public void setSide2(int s2)
    {
        side2 = s2;
    }

    public  int getSide3()
    {
        return side3;
    }

    public void setSide3(int s3)
    {
        side3 = s3;
    }

    public double findArea(int side_1, int side_2, int side_3)throws InvalidValueException 
    {
        int s, a, b,c;
        a = side_1;
        b = side_2;
        c = side_3;
        s = ((a + b + c)/2);
        area = Math.sqrt(s*(s-a)*(s-b)*(s-c));
        //area =
        return area;
    }



public void validateTriangle(int sidea, int sideb, int sidec) throws InvalidValueException
    {
        try
        {
        if((sidea + sideb > sidec)||(sideb + sidec > sidea)||(sidea + sidec > sideb))
        {
            findArea(side1,side2,side3);
        }
        }
        catch(InvalidValueException excep)
                {
                    message = excep.getMessage();
                }
    }

}

class InvalidValueException extends Exception
{
    public InvalidValueException()
    {
        super("These values cannot form a valid triangle");
    }
}

What I would like to know is not that I am missing something (do let me know if I am missing something though) but main objective of asking here is, is this the right way to answer this question?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:06:22+00:00Added an answer on June 12, 2026 at 7:06 pm

    You have the right idea. You’re just not combining your code to match your assignment.

    Constructor that sets the length of the three sides to the values passed in. The constructor should throw an InvalidValueException object when the values are not able to form a triangle.

    A class constructor would look like this.

    public Triangle_getvalues(int a, int b, int c) throws InvalidValueException {
        validateTriangle(a, b, c);
        setSide1(a);
        setSide2(b);
        setSide3(c);
    }
    

    Your validateTriangle method shouldn’t try to both throw the InvalidValueException and catch the InvalidValueException. Choose one or the other.

    Your validateTriangle method doesn’t need to call or perform the findArea method. You just need to determine whether or not the input lengths make a valid triangle.

    Here’s how it should work:

     public void validateTriangle(int sidea, int sideb, int sidec) 
         throws InvalidValueException
     {
        if ((sidea + sideb > sidec) || (sideb + sidec > sidea)
            || (sidea + sidec > sideb))
        {
    
        } else {
            throw new InvalidValueException;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just asked a question in a technical interview that I was a
this isnt technical question on how to connect to SQL server i know how
Hi All I saw this question posted on a site asked in a technical
confused - given a track uri, I can get one album but possibly more
Mildly confused. I have a combobox that is databound to a list of strings.
Pretty confused right now, while i feel i know a bit about vhosts this
Totally confused here. I have a PARENT UIViewController that needs to pass an NSMutableArray
Totally confused by this one... We have a WAMPServer installation set up, running a
I have a technical problem about my architecture. I explain my goal with this
Yesterday I had a team leader of another team say that they took a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.