Hello I am having a bit of trouble on creating a Java Progra

Hello I am having a bit of trouble on creating a Java Program. I have to do the following steps:

-Open a suitable text editor on your computer and write the program code which will allow the user to enter the necessary input items A , B , C , D , E , and F and then use these items to compute both the values of x and y.  

-Use a method called SolveSystem() that will be used to receive the A , B , C , D , E and F coefficients and compute the value of the variables x and y .

-Use looping techniques to allow the user to run the program repeatedly until it is desired to terminate the program.

The following are the exercises have to use in the program.

Exercises        (Cramer’s Rule)

                        (a)        -2x - 5y =-08

            -3x + 8y =-50

                        solution:            x = __________           y = __________                      

                                   

                        (b)        -4x +5y =-30.5

-2x + 5y =-31.5

                        solution:            x = __________           y = __________

                        (c)        -0.05x - 0.20y =-0.405

-0.10x + 0.14y =-0.355

            solution:            x = __________           y = __________

Any help would be helpful.

Thank you for your help and time.

Solution

/* we solve the linear system
* ax+by=e
* cx+dy=f
*/

// EquationSolver.java
import java.util.Scanner;

class EquationSolver
{

public static void SolveSystem(double a, double b, double c, double d, double e, double f)
{
double x, y;

double dd=(a*d)-(b*c);

if(dd==0)
{
System.out.println( \"Equation has no solutions\ \");
}
else
{
x = (e * d - b * f) / (a * d - b * c);
y = (a * f - e * c) / (a * d - b * c);
  
System.out.println(\"Solution:\ \\tx : \"+x+ \"\ \\ty : \"+y);
}
}
public static void main (String [] args)
{
Scanner scan = new Scanner(System.in);
double a,b,c,d,e,f;   

System.out.print( \"Enter the value of a,b,c,d,e,f to solve 2x2 system of linear equations: \");
a = scan.nextDouble();
b = scan.nextDouble();
c = scan.nextDouble();
d = scan.nextDouble();
e = scan.nextDouble();
f = scan.nextDouble();

SolveSystem(a,b,c,d,e,f);
}
}


/*
output:

Enter the value of a,b,c,d,e,f to solve 2x2 system of linear equations: -4 5 -2 5 -30.5 -31.5
Solution:
   x : -0.5
   y : -6.5


Enter the value of a,b,c,d,e,f to solve 2x2 system of linear equations: -2 -5 -3 8 -8 -50
Solution:
   x : 10.129032258064516
   y : -2.4516129032258065

Enter the value of a,b,c,d,e,f to solve 2x2 system of linear equations: -0.55 0.2 -0.1 0.14 -0.405 -0.355
Solution:
   x : -0.25087719298245587
   y : -2.714912280701754

*/

Hello I am having a bit of trouble on creating a Java Program. I have to do the following steps: -Open a suitable text editor on your computer and write the pro
Hello I am having a bit of trouble on creating a Java Program. I have to do the following steps: -Open a suitable text editor on your computer and write the pro

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site