# Java program to get real solutions of quadratic equation

Write a Java program that prints all real solutions to the quadratic equation ax^2 + bx + c = 0. Read in a, b, c and use the quadratic formula. If the discriminant (b^2 – 4ac) is negative, display a message stating that there are no real solutions.

Implement a class QuadraticEquation whose constructor receives the coefficients a, b, c of the quadratic equation. Supply methods getSolution1 and getSolution2 that get the solutions, using the quadratic formula, or 0 if no solution exists. The getSolution1 method should return the smaller of the two solutions.

Don't use plagiarized sources. Get Your Custom Essay on
Java program to get real solutions of quadratic equation
From \$10/Page

Supply a boolean method hasSolutions that returns false if the discriminant is negative.

Use the following class as your tester class:

/**
This program tests the QuadraticEquation class.
*/
{
public static void main(String[] args)
{
System.out.println(eq1.hasSolutions());
System.out.println(“Expected: true”);
System.out.println(eq1.getSolution1());
System.out.println(“Expected: -2”);
System.out.println(eq1.getSolution2());
System.out.println(“Expected: 1”);

System.out.println(eq2.hasSolutions());
System.out.println(“Expected: true”);
System.out.println(eq2.getSolution1());
System.out.println(“Expected: -2”);
System.out.println(eq2.getSolution2());
System.out.println(“Expected: 1”);
Solution Preview
Required QuadraticEquation class has been implemented in the same file.

{
private int a, b, c, discriminant;

QuadraticEquation (int a, int b, int c)
{
this.a = a;
this.b = b;
this.c = c;
discriminant = (b*b) – 4*a*c;
}

boolean hasSolutions ()
{
if (discriminant < 0)
{
System.out.println(“There are no real solutions.”);
return false;
}
else

Solution Summary

To continue with the answer check on mycoursewriter.com/

Order NOW For A 35% Discount!
Pages (550 words)
Approximate price: -

Why Choose Us

Quality Homework Writing

Do you need to ace your test? We have qualified writers to assist you in writing 100% quality homework writing. Mycoursewriter offers students unique and personalized custom papers that help them in getting good grades. Our academic experts will assist you with your dissertation papers, thesis writing, research papers, term papers, and case study homework help. Our writers are experienced and have perfected the art of crafting the best essay writing papers regardless of your academic level. Order now and get our superb homework writing services.

A student needs professional assistance outside class time. Before hiring our writers, they undergo thorough tests and strict educational backgrounds. After passing a test, our writers undergo training to ensure they deliver expert professional papers to our customers. We ensure they meet the timely delivery of papers and follow our customers' provided instructions. Every writer is an ENL writer and is from the USA, Canada, UK, or Australia. Our experts approach papers effectively depending on their area of specialization.

Affordable Price Guarantees

Is the deal too good to be true? Mycoursewriter is the most affordable assignment help website on the market. We consider students' daily needs for academic help. Our paper costs are reasonably priced to approximately 90% of students around the globe. Our main aim is to ensure students achieve academic excellence, and we believe inconsiderable prices should not hinder students from getting quality homework writing help. In case of any dissatisfaction, we offer unlimited revisions and rewrites without extra charges.

Timely delivery of papers

The ultimate deal-breaker in achieving good grades is submitting imitative papers. Plagiarism is a breach of examination standards and has serious consequences. Students need to deliver papers written in their understanding by paraphrasing their research findings and relevant citations. Our expert's primary consideration is providing free plagiarized papers that meet the lecturers' requirements. Our editors will proofread your paper before delivery ad ensure your papers will not be substandard. We guarantee extreme originality, and in case of any customer concerns, we offer a plagiarism report.

All Round the clock Customer Support

Our website is user-friendly and super useful! Mycoursewriter is the most trusted online writing website always available to provide you with assignment writing services that you need. Our primary concern is meeting customer need specifications by our friendly customer support team that Is available all the time. Our website usability is self-learnable but in case of any problem, feel free to contact us directly through our website email: support@mycourserwiter.com. We have diligently satisfied thousands of students, and you can witness this on our sites' review page.

Try it now!

## Calculate the price of your order

We'll send you the first draft for approval by at
Total price:
\$0.00

How it works?

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Advantages of Using Our Assignment writing Services

Mycoursewriter welcomes you for superb essay writing services. We are a legit site offering help with your most challenging homework writing assignments at affordable prices. Your essay paper will be assigned to a professional writer who will craft the paper from scratch according to your provided instructions.

## Essay Writing and Proofreading Services

Essay writing is a common assignment writing for most college students. It takes a lot of time to craft a complete perfect essay. Mycourserwiter offers the best essay writing and proofreading services for most college students. Your paper is assigned to an expert writer who does thorough research on fresh ideas and personalizes your essay paper according to your assignment writing guidelines. Our essays are entirely exceptional and undergo a strict procedure that includes papers free from plagiarism and thorough proofreading.