Giải phương trình bậc 2 java

Share:

/* * lớn change this license header, choose License Headers in Project Properties. * khổng lồ change this template file, choose Tools | Templates * and xuất hiện the template in the editor. */package bai977.ax2.giaipt2;import static java.lang.Math.sqrt;import java.util.Scanner;/** * *

Bạn đang đọc: Giải phương trình bậc 2 java

author MTLS */public class giaipt2 { public static void main(String<> args) { int a, b, c; float x1, x2, detail; Scanner scan = new Scanner(System.in); System.out.println("Nhap a= "); a = scan.nextInt(); System.out.println("Nhap b= "); b = scan.nextInt(); System.out.println("Nhap c= "); c = scan.nextInt(); detail = (b*b - (4*a*c))/(2*a); if (detail
*

/* * lớn change this license header, choose License Headers in Project Properties. * to change this template file, choose Tools | Templates * and mở cửa the template in the editor. */package bai977.ax;import java.util.Scanner;/** * *
author MTLS */public class giaipt1 public static void main(String<> args) int a, b; double x; Scanner scan = new Scanner(System.in); System.out.print("nhap a = "); a = scan.nextInt(); System.out.print("nhap b = "); b = scan.nextInt(); if(a==0) if(b==0) System.out.println("PT VSN"); else System.out.println("PT VN"); else x = -b/a; System.out.println("PT co nghiem x= " + x);

*

Xem thêm: Đáp Án Đề Thi Anh Văn Thpt Quốc Gia 2017 Môn Tiếng Anh Chính Thức ❣️✔️

package javalesson2;import java.util.Scanner;public class ex08 { public static void main(String<> args) { double a, b, c, x1, x2, delta; String ketQua = ""; Scanner scanner = new Scanner(System.in); vị System.out.print("Nhập a (a # 0): "); a = scanner.nextDouble(); while (a == 0); System.out.print("Nhập b: "); b = scanner.nextDouble(); System.out.print("Nhập c: "); c = scanner.nextDouble(); delta = Math.pow(b, 2) - 4 * a * c; if (delta

*

/* * lớn change this license header, choose License Headers in Project Properties. * to lớn change this template file, choose Tools | Templates * and open the template in the editor. */package newpackage;import static java.lang.Math.sqrt;import java.text.DecimalFormat;import java.util.Scanner;/** * *
author Admin */public class NewClass { public static void main(String<> args) { // Bai 2 : Scanner scan = new Scanner(System.in); float a, b, c, x; System.out.println("Nhap a : "); a = scan.nextFloat(); System.out.println("Nhap b : "); b = scan.nextFloat(); System.out.println("Nhap c : "); c = scan.nextFloat(); if(a == 0) if(b == 0) if(c == 0) System.out.println("PTVN"); else System.out.println("PTVSN"); else x = -c/b; System.out.println("PT teo 1 nghiem duy nhat : " + x); else { float delta; delta = b*b - 4*a*c; if(delta

/* * khổng lồ change this license header, choose License Headers in Project Properties. * to lớn change this template file, choose Tools | Templates * and mở cửa the template in the editor. */package newpackage;import java.text.DecimalFormat;import java.util.Scanner;/** * *
author Admin */public class NewClass public static void main(String<> args) // Bai 1 : int a, b; double nghiem; DecimalFormat decimalFormat = new DecimalFormat("#.##"); Scanner scanner = new Scanner(System.in); System.out.println("Nhap a: "); a = scanner.nextInt(); System.out.println("Nhap b: "); b = scanner.nextInt(); System.out.println("Phuong trinh nhap vao la : " + a + "x + " + b + " = 0."); if (a == 0) if (b == 0) System.out.println("Phuong trinh VSN"); else System.out.println("Phuong trinh VN"); else nghiem = (double) -b / a; System.out.println("Phuong trinh teo nghiem x = " + decimalFormat.format(nghiem) + ".");

Bài viết liên quan