Đang xem: Viết chương trình giải phương trình bậc 2 java
T1907AKhoá học java căn bảnjava basicC1907LJavaFree02. Biến + Toán Tử + Mệnh Đề Điều KiệnT2008AToday_T2008A
(1) Nguyễn Hoàng Anh
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */package bai977.ax2.giaipt2;import static java.lang.Math.sqrt;import java.util.Scanner;/** * *
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
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open 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: Cách Tính Diện Tích Xây Dựng Mái Ngói, Cách Tính Diện Tích Mái Ngói Đơn Giản, Chính Xá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); do { 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
/* * To change this license header, choose License Headers in Project Properties. * To 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 co 1 nghiem duy nhat : ” + x); } } else { float delta; delta = b*b – 4*a*c; if(delta
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open 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 co nghiem x = ” + decimalFormat.format(nghiem) + “.”); } }}
Xem thêm: Giải Vở Bài Tập Toán Lớp 3 Tập 2 Bài 123 : Luyện Tập, Giải Vở Bài Tập Toán Lớp 3 Tập 2
Chúng tôi tạo ra website nay với mong muốn chia sẻ những kiến thức và kinh nghiệm thực tiễn mà chung tôi đã có được – nhằm giúp cho những bạn mới bắt đầu học lập trình trở nên dễ dàng hơn và có lộ trình học cụ thể & rút ngắn thời gian học