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 8848327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:23:55+00:00 2026-06-14T12:23:55+00:00

I am trying to negate a polynomial expression so that the following tests are

  • 0

I am trying to negate a polynomial expression so that the following tests are correct with my polynomial expressions being defined as Term(coefficient, exponent). So my public Term negate() throws Overflow method passes these tests.

Term(min,2) -> expected = Overflow
Term(-7,2) -> expected = (7,2)
Term(0,2) -> expected = (0,2)
Term(7,2) -> expected = (-7,2)
Term(max,2) -> expected = (-max,2)

EDIT: I have the following method within Term:

public Term negate() throws Overflow {

}

and the following in the Term constructor:

public Term(int c, int e) throws NegativeExponent{
    if (e < 0) throw new NegativeExponent();
    coef = c;
    expo = (c == 0 && e != 0) ? 0 : e;
}

The tests above are in a seperate JUnit file, but I am trying to make the negate() method pass the tests.

  • 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-14T12:23:56+00:00Added an answer on June 14, 2026 at 12:23 pm

    I can only answer this because I answered one of your previous questions… so you might want to clarify a little more in your post.

    Perhaps you want

    public Term negate() throws Overflow, NegativeExponent {
        if (coef == min)
            throw new Overflow();
        return new Term(-coef, expo);
    }
    

    You might want to consider renaming Overflow to something more specific as well (so as to fully distinguish it from a StackOverflowError).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use regular expressions to match a string that does not contain
I'm trying to write a regular expression that will validate a variable assignments in
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
Trying to understand what's the correct way of implementing OpenID authentication with Spring Security.
Hey All! I'm trying to construct a query that is something like this: Where
I'm trying to find a way to negate sentences based on POS-tagging. Please consider:
(iPhone) I'm trying to make it so that the user can rotate an object
Trying to setup a SQL stored procedure that if the variable passed to it
I'm using Netbeans, and trying to get a program Rational to run, so that
If you reflect over WindowsBase.dll > MS.Internal.DoubleUtil.AreClose(...) you'll get the following code: public static

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.