Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication3;
- import java.util.Scanner;
- public class JavaApplication3 {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- double a, b, c, d;
- p("\nDigite o elemento A: ");
- l(a);
- p("\nDigite o elemento B: ");
- l(b);
- p("\nDigite o elemento C: ");
- l(c);
- p("\n====================\n");
- p(a + "x² + " + b + "x + " + c + " = 0\n");
- p("(-b ± Raiz(b² - 4 . a . c) ) / 2 . a\n");
- p("(-b ± Raiz(" + b + "² - 4 . " + a + " . " + c + ") ) / 2 . a\n");
- p("(-b ± Raiz(" + Math.pow(b,2) + " - " + 4 * a * c + ") ) / 2 . a\n");
- d = Math.pow(b,2) - 4 * a * c;
- if(d < 0){
- p("Raiz do delta não pertence aos Reais. (Raiz(" + d + ") != Reais)");
- }
- else
- {
- p("(-b ± Raiz(" + d + ") ) / 2 . a\n");
- p("(-b ± Raiz(" + d + ") ) / " + 2 * a + "\n");
- p("(" + i(b) + " ± Raiz(" + d + ") ) / " + 2 * a + "\n");
- p(" -------------------\n");
- p(" x1 = (" + i(b) + " + " + r(d) + ") ) / " + 2 * a + "\n");
- p(" x1 = (" + (i(b) + r(d)) + ") ) / " + 2 * a + "\n");
- p(" x1 = " + (i(b) + r(d)) / 2 * a + "\n");
- p(" -------------------\n");
- p(" x2 = (" + (i(b)) + " - " + r(d) + ") ) / " + 2 * a + "\n");
- p(" x2 = (" + (i(b) - r(d)) + ") ) / " + 2 * a + "\n");
- p(" x2 = " + (i(b) - r(d)) / 2 * a + "\n");
- p(" -------------------\n");
- p("Done!!");
- }
- }
- public static void p(String stri){
- System.out.print(stri);
- }
- public static double r(double n){
- return Math.sqrt(n);
- }
- public static double i(double n){
- return (n * -1);
- }
- public static void l(double n){
- n = input.nextInt();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement