#### Java Mathematical Solutions

 Previous Chapter Next Chapter
 Note Here I am using, OS : Linux (Ubuntu 12.04) IDE : Eclipse Tool Eclipse : Juno (Version 4.2.0) Package : Default package A. Factorisation example in Java Factorisation_Ex1.java ```import java.util.Scanner;   public class Factorisation_Ex1 { public static void main(String srga[]) { Scanner scan = new Scanner(System.in); double a = 0, b = 0, c = 0, x1, x2; System.out.println("Your equation is just like below :\nax^2+bx+c\n"); try { System.out.println("Enter the Co-efficient of x^2 (a) : "); a = Double.parseDouble(scan.nextLine()); System.out.println("Enter the Co-efficient of x (b) : "); b = Double.parseDouble(scan.nextLine()); System.out.println("Enter the constant value (c) : "); c = Double.parseDouble(scan.nextLine()); } catch (Exception e) { e.printStackTrace(); } x1 = (-b + (Math.sqrt( (b*b) - (4*a*c)))) / (2*a); x2 = (-b - (Math.sqrt( (b*b) - (4*a*c)))) / (2*a); System.out.println(x1); System.out.println(x2); } } ``` Sample Output ```Your equation is just like below : ax^2+bx+c Enter the Co-efficient of x^2 (a) : 1 Enter the Co-efficient of x (b) : -5 Enter the constant value (c) : 6 x1 : 3.0 x2 : 2.0 ``` B. Differentiation example in Java Differentiation_Ex1.java ```import java.util.Scanner;   public class Differentiation_Ex1 { public static void main(String args[]) { Scanner scan = new Scanner(System.in); System.out.println("Let us consider our equation is like below :" + "\nax^n + bx^n-1 + ...... + z"); System.out.println("\nEnter n value :"); int n = Integer.parseInt(scan.nextLine()); int temp = n; float num[] = new float[n+1]; for(int i=0; i<=n; i++) { System.out.println("Enter the Co-efficient of x^" + (temp-i) + " :"); num[i] = Float.parseFloat(scan.nextLine()); } for(int i=0; i
 Previous Chapter Next Chapter