SHOW:
|
|
- or go back to the newest paste.
1 | package javaapplication3; | |
2 | import java.util.Scanner; | |
3 | public class JavaApplication3 { | |
4 | public static void main(String[] args) { | |
5 | Scanner input = new Scanner(System.in); | |
6 | double a, b, c, d; | |
7 | p("\nDigite o elemento A: "); | |
8 | - | a = input.nextInt(); |
8 | + | l(a); |
9 | p("\nDigite o elemento B: "); | |
10 | - | b = input.nextInt(); |
10 | + | l(b); |
11 | p("\nDigite o elemento C: "); | |
12 | - | c = input.nextInt(); |
12 | + | l(c); |
13 | p("\n====================\n"); | |
14 | p(a + "x² + " + b + "x + " + c + " = 0\n"); | |
15 | p("(-b ± Raiz(b² - 4 . a . c) ) / 2 . a\n"); | |
16 | p("(-b ± Raiz(" + b + "² - 4 . " + a + " . " + c + ") ) / 2 . a\n"); | |
17 | p("(-b ± Raiz(" + Math.pow(b,2) + " - " + 4 * a * c + ") ) / 2 . a\n"); | |
18 | d = Math.pow(b,2) - 4 * a * c; | |
19 | if(d < 0){ | |
20 | p("Raiz do delta não pertence aos Reais. (Raiz(" + d + ") != Reais)"); | |
21 | } | |
22 | else | |
23 | { | |
24 | p("(-b ± Raiz(" + d + ") ) / 2 . a\n"); | |
25 | p("(-b ± Raiz(" + d + ") ) / " + 2 * a + "\n"); | |
26 | p("(" + i(b) + " ± Raiz(" + d + ") ) / " + 2 * a + "\n"); | |
27 | p(" -------------------\n"); | |
28 | p(" x1 = (" + i(b) + " + " + r(d) + ") ) / " + 2 * a + "\n"); | |
29 | p(" x1 = (" + (i(b) + r(d)) + ") ) / " + 2 * a + "\n"); | |
30 | p(" x1 = " + (i(b) + r(d)) / 2 * a + "\n"); | |
31 | p(" -------------------\n"); | |
32 | p(" x2 = (" + (i(b)) + " - " + r(d) + ") ) / " + 2 * a + "\n"); | |
33 | p(" x2 = (" + (i(b) - r(d)) + ") ) / " + 2 * a + "\n"); | |
34 | p(" x2 = " + (i(b) - r(d)) / 2 * a + "\n"); | |
35 | p(" -------------------\n"); | |
36 | p("Done!!"); | |
37 | } | |
38 | } | |
39 | public static void p(String stri){ | |
40 | System.out.print(stri); | |
41 | } | |
42 | public static double r(double n){ | |
43 | return Math.sqrt(n); | |
44 | } | |
45 | public static double i(double n){ | |
46 | return (n * -1); | |
47 | } | |
48 | public static void l(double n){ | |
49 | n = input.nextInt(); | |
50 | } | |
51 | } |