• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
projectsgeek

ProjectsGeek

Download Mini projects with Source Code, Java projects with Source Codes

  • Home
  • Java Projects
  • C++ Projects
  • VB Projects
  • PHP projects
  • .Net Projects
  • NodeJs Projects
  • Android Projects
    • Project Ideas
      • Final Year Project Ideas
      • JSP Projects
  • Assignment Codes
    • Fundamentals of Programming Language
    • Software Design Laboratory
    • Data Structure and Files Lab
    • Computer Graphics Lab
    • Object Oriented Programming Lab
    • Assembly Codes
  • School Projects
  • Forum

Finding Real solutions of Quadratic equations in Java code

September 16, 2013 by ProjectsGeek Leave a Comment

Quadratic equations Real solutions in Java code

Write a Real solutions of Quadratic equations java code which will prints all real solutions of the user entered quadratic equation of form ax2+bx+c=0. Program should take the a,b,c  values and use the quadratic formula to calculate real solutions.

If the Calculated discriminant which is b2-4ac is negative, Program should display output with the generated message as  that there are no real solutions.

We can use sqrt functions for calculating Real solutions of Quadratic equations. Declare a.b,c and d as integer data types and e,f as double type.

Algorithm for Finding Real solutions of Quadratic equations in Java

  • Take input from user as values of a,b,c .
  • Print values to screen for user confirmation.
  • Calculate b2-4ac .
  • if b<0 no real Roots .
  • else Apply these formulas :

                                e=((-b+Math.sqrt(d))/(2*a))
                               e=((-b-Math.sqrt(d))/(2*a))

  • Print both the values to screen.
import java.lang.*;
import java.util.*;

public class Quadraticequation {

	public static void main(String args[])
	{
	int a,b,c,d;
	double e,f;
	System.out.println("Enter a,b,c values");

	Scanner sc = new Scanner(System.in);
	a=sc.nextInt();
	b=sc.nextInt();
	c=sc.nextInt();
	System.out.println("Enterd values are a="+a+" b="+b+" c="+c);
	d=(b*b)-(4*a*c);
	if(d<0)
	{
	  System.out.println("No real roots");
	}else
	{
	e=((-b+Math.sqrt(d))/(2*a));
	f=((-b-Math.sqrt(d))/(2*a));
	System.out.println("Roots are "+e+" "+f);
	}
     }
}

 Output of Real solutions of Quadratic equations Program

Quadratic equations Real solutions
Quadratic equations Real solutions in Java
Real solutions of Quadratic equations in Java

Other Projects to Try:

  1. Exception Handling In java
  2. File Handling program using Java
  3. Moving Balls mini project using Java Applet
  4. Public and Private Keywords
  5. Roots of a quadratic equation in C Language

Filed Under: Uncategorized

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Tags

.Net Projects Download Android Project Ideas Android Projects Angular 2 Assembly Codes C # Projects C & C++ Projects C++ Projects Class Diagrams Computer Graphics Database Project Data Mining Projects DataScience Projects Datastructure Assignments Download Visual Basic Projects Electronics project Hadoop Projects Installation Guides Internet of Things Project IOS Projects Java Java Interview Questions Java Projects JavaScript JavaScript Projects java tutorial JSON JSP Projects Mechanical Projects Mongodb Networking Projects Node JS Projects OS Problems php Projects Placement Papers Project Ideas Python Projects seminar and presentation Struts

Search this Website


Footer

Download Java Project
Download Visual Basic Projects
Download .Net Projects
Download VB Projects
Download C++ Projects
Download NodeJs Projects
Download School Projects
Download School Projects
Ask Questions - Forum
Latest Projects Ideas
Assembly Codes
Datastructure Assignments
Computer Graphics Lab
Operating system Lab
australia-and-India-flag
  • Home
  • About me
  • Contact Form
  • Submit Your Work
  • Site Map
  • Privacy Policy