Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Chapter3_3CramersRule {
- public static void main(String[] args) {
- Scanner kb = new Scanner (System.in);
- System.out.println("Enter a,b,c,d,e,and f");
- double a = kb.nextDouble();
- double b = kb.nextDouble();
- double c = kb.nextDouble();
- double d = kb.nextDouble();
- double e = kb.nextDouble();
- double f = kb.nextDouble();
- double x = 0; // you must initialize the variable to something. 0 is good in this case
- double y = 0; // you must initialize the variable to something. 0 is good in this case
- if ((a*d - b*c) !=0){
- x = (e*d - b*f)/(a*d - b*c);
- y = (a*f - e*c)/(a*d - b*c);
- System.out.println("x is "+ x + " and y is "+ y);
- }
- else
- System.out.println("The equation has no solutions");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement