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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:57:55+00:00 2026-06-18T01:57:55+00:00

Im writing a program, that takes the a, b, and c from an equation,

  • 0

Im writing a program, that takes the a, b, and c from an equation, and uses them to find x using the formula:
http://www.purplemath.com/modules/quads/qform01.gif.

The problem im getting, is that when I plugin the equation 1x^2 +3x +4 I get x = -Infinity and x = infinity instead of x = 1 and x = -4.

Heres my code:

Class 1:

    public class quadratictest
    {
        public static void main(String args[])
        {
            DecimalFormat df = new DecimalFormat("#.###");
            System.out.println("--------------------------------------------------");
            System.out.println("               ~Quadratic Formula~");
            System.out.println("--------------------------------------------------");
            System.out.println("in a polynomial, there are 3 important numbers used");
            System.out.println("to figure out x. they are a, b, and c, shown below.\n");
            System.out.println("\t\t1x^2 +3x +4");
            System.out.println("\t\t^     ^   ^");
            System.out.println("\t\ta     b   c");
    Scanner input = new Scanner(System.in);
           System.out.print("\nPlease type a, b, and c here[a b c]: ");
            int a = input.nextInt();
            int b = input.nextInt();
            int c = input.nextInt();
            mathey quad = new quadsong(a,b,c);
        System.out.println("------------");
        System.out.println(quad.solveb());
        System.out.println(quad.solvea());
        //System.out.println("x =" +df.format(quad.solvea()));
        //System.out.println("x =" +df.format(quad.solveb()));
        System.out.println("------------");
    }
}

Class 2:

    import java.util.*;
    import java.io.*;
    import java.text.DecimalFormat;
            /**
     * Write a description of class quadsong here.
     * 
     * @author (your name) 
     * @version (a version number or a date)
     */
    public class mathey
    {
        int a;int b;int c;
        double solution1;
        double solution2;
          public mathey(int aN, int bN, int cN)
        {
            int a  = aN;
            int b = bN;
            int c = cN;
            solvea();
            solveb();
        }
        public double solvea()
        {
         solution1 = ( (b*-1) + Math.sqrt((b^2)-(4*a*c)))/(a+a);
          if (solution1 == Math.floor(solution1))
         {
         return solution1;
        }
        else
        {
            return 0;
        }
        }
            public double solveb()
        {
         solution2 = ( (b*-1) - Math.sqrt((b^2)-(4*a*c)))/(2*a);
         if (solution2 == Math.floor(solution2))
         {
         return solution2;
        }
        else
        {
            return 0;
        }
        }
    }

heres my output:

    --------------------------------------------------
                   ~Quadratic Formula~
    --------------------------------------------------
    in a polynomial, there are 3 important numbers used
    to figure out x. they are a, b, and c, shown below.

            1x^2 +3x +4
            ^     ^   ^
            a     b   c

    Please type a, b, and c here[a b c]: 1 3 4
    ------------
    x =Infinity
    x =-Infinity
    ------------

Whats going wrong? Thanks in advance!
P.S Sorry for the code formatting, idk why its not working like I want on here haha

  • 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-18T01:57:56+00:00Added an answer on June 18, 2026 at 1:57 am

    The problem that you’re having here is that: 1x^2 + 3x + 4 has no roots. It’s more of a math error than anything else.

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

Sidebar

Related Questions

I am writing a program that takes letters and converts them to telephone numbers.
Overview I am writing a Ruby program that uses data from mysql queries to
I am writing a program that takes all of the text from a text
I am writing a program that takes in an input file from the user.
So im writing c++ program, that takes a integer from input file, multiply it
I'm writing a program that's parsing an XML file to java objects using smooks.
I am writing a program that takes a file and splits it up into
I am trying to make a small program that takes in input from a
I've got a GUI C++ program that takes a shell command from the user,
So I am currently writing a part of a program that takes user text

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.