*****************************************************************************
PLEASE DO UPVOTE IF THE ANSWER IS HELPFUL AS IT GIVES THE
CONFIDENCE TO HELP MORE STUDENTS
*****************************************************************************
In case If I have not answered completely, it's because Chegg
allows me to answer a specific no of questions including the
subparts, so please do post the rest of the questions as a separate
query as per Chegg Guidelines. Thank you :)
*****************************************************************************
import java.util.*;
class Hello {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a, b, c, x, y, z;
int p, q;
a = sc.nextInt();
b = sc.nextInt();
c = sc.nextInt();
x = sc.nextInt();
y = sc.nextInt();
z = sc.nextInt();
int flag = 0;
for (int i = -10; i <= 10; i++) {
for (int j = -10; j <= 10; j++) {
if ((a * i + b * j == c) && (x * i + y * j == z)) {
System.out.println(i + " " + j);
flag = 1;
}
if (flag == 1)
break;
}
if (flag == 1)
break;
}
if (flag == 0) {
System.out.println("No solution");
}
}}
Java 6.11 LAB: Brute force equation solver Numerous engineering and scientific applications require finding solutions to...