Guest User

Untitled

a guest
Mar 24th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. public class LinearEquationResolver {
  2. public static void main(String[] args) {
  3. System.out.println("Linear Equation Resolver");
  4. System.out.println("Given a equation as 'a * x + b = 0', please enter constants:");
  5. java.util.Scanner sc = new java.util.Scanner(System.in);
  6. System.out.println("Enter a:");
  7. double a = sc.nextInt();
  8. System.out.println("Enter b:");
  9. double b = sc.nextInt();
  10. if (a != 0) {
  11. double answer = - b / a;
  12. System.out.printf("Equation pass with x = %f!\n", answer);
  13. } else {
  14. if (b == 0) {
  15. System.out.print("The solution is all x!");
  16. } else {
  17. System.out.print("No solution!");
  18. }
  19. }
  20. }
  21. }
Add Comment
Please, Sign In to add comment