Code:
import java.util.Scanner;
class practical2 {
public static void main (String args[])
{
double a,b,c,d,e,f,x,y;
Scanner s=new Scanner(System.in);
System.out.println("Two Equations are: a*x+b*y=e and c*x+d*y=f\nWhere a,b,c,d,e,f are conctant and x,y are variables\n Now enter the values of contant to Solve Equation");
System.out.print("Enter value of a:");
a=s.nextDouble();
System.out.print("Enter value of b:");
b=s.nextDouble();
System.out.print("Enter value of c:");
c=s.nextDouble();
System.out.print("Enter value of d:");
d=s.nextDouble();
System.out.print("Enter value of e:");
e=s.nextDouble();
System.out.print("Enter value of f:");
f=s.nextDouble();
x=(e*d-b*f)/(a*d-b*c);
y=(a*f-e*c)/(a*d-b*c);
System.out.print("Value of x and y is : "+x+" " +y);
}
}
Comments
Post a Comment