Java

Calculate Linear Equation using Java

Calculate Linear Equation using Java
// linear equation program 

import java.io.*; 
class ssvli 
{ 
public static void main(String arg[]) 
{ 
float x1,x2,a,b,c,d,m,n,z; 
a=2;b=3;c=4;d=5;m=6;n=8; 
System.out.println("1st linear equation is=> "+a + "x1 +" + b +"x2=" +m); 
System.out.println("2ed linear equation is=> "+c + "x1 +" + d +"x2=" +n); 
System.out.println("using formula and we get the val of x1 & x2 as:"); 
z=(a*d)-(c*b); 
if(z==0) 
{ 
System.out.println("************the denominator (a*d)-(c*b) is not equal to zero"); 
} 
else 
{ 
x1=(m*d-b*n)/(a*d-c*b); 
x2=(n*a-m*c)/(a*d-c*b); 
System.out.println(" x1="+x1); 
System.out.println(" x2="+x2); 
} 
} 

}
Senthilvelan Sambamoorthy

Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.