Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.lang.Math;
- import java.util.Scanner;
- public class math {
- public static void main(String[] args) {
- Scanner ascan = new Scanner(System.in);
- Scanner bscan = new Scanner(System.in);
- Scanner cscan = new Scanner(System.in);
- System.out.println("A veertiiba?");
- String astring = ascan.nextLine();
- System.out.println("B veertiiba?");
- String bstring = bscan.nextLine();
- System.out.println("C veertiiba?");
- String cstring = cscan.nextLine();
- int a = Integer.parseInt(astring);
- int b = Integer.parseInt(bstring);
- int c = Integer.parseInt(cstring);
- int y;
- if (b > 0) {
- int x = b * 2;
- y = b - x;
- }else{
- int x = b * (-2);
- y = b + x;
- }
- int l = a * 2;
- int m = (b * b) - (4 * a * c);
- double n = Math.sqrt(m);
- double o = y + n;
- double p = y - n;
- double f1 = o / l;
- double f2 = p / l;
- System.out.println("x1 = " + f1);
- System.out.println("x2 = " + f2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment