By GokiSoft.com| 10:02 18/01/2021|
Học JS

Bài tập - Giải phương trình bậc nhất ax + b = 0 BT2004

Tạo 1 website khi bắt đầu bật chương trình lên thì thực hiện các bước như sau

Giải phương trình bậc nhất (ax + b = 0)

Bước 1 : Hiển thị prompt để nhập giá trị cho a

Bước 2: Nhập giá tri cho b bằng prompt

Bước 3 : In kết quả x ra màn hình

Tags:

Liên kết rút gọn:

https://gokisoft.com/2004

Bình luận

avatar
Nguyễn Anh Vũ [T2008A]
2020-10-20 09:35:01


#pt bac nhat.html


<!DOCTYPE html>
<html>
<head>
	<title>Bai Tập 2</title>
	<meta charset="utf-8">
	<style type="text/css">
		.row{
			width: 100%;
			height: 20px;
			background-color: #FFFF99;
			color: black
		}
		.menu{
			width:100%;
			height:35px;
			background-color: #CCFFFF;
			padding-top: 10px;
			left: 10px;
			color: white
		}
	</style>
</head>
<body>
<div class="row">
		Giải Phương Trình Bậc nhất ax+b=0
</div>
<div class="menu">
	<button onclick="NhapA()" style="background-color: #CCFF66" > Nhập A</button>
	<button onclick="NhapB()" style="background-color: #CCFF66"> Nhập B</button>
 	<button onclick="Ketqua()" style="background-color: #CCFF66"> Tổng ax + b =</button>
</div>
<script type="text/javascript">
	var a,b;
	function NhapA(){
		a=parseInt(prompt('NhapA'))
	}
	function NhapB(){
		b=parseInt(prompt('NhapB'))
	}
	function Ketqua(){
		if (a == 0) {
				if (b == 0) {
					alert('ptvsn')
				}else{
					alert('ptvn')
				}
			}else{
				x = -b/a
				alert(x)
			}
		}
	</script>

</body>


avatar
Trần Thị Khánh Huyền [T2008A]
2020-10-18 10:29:18


#giaiPTbac1.html


<!DOCTYPE html>
<html>
<head>
	<title>giaiPTbac1</title>
	<meta charset="utf-8">
</head>
<body>
<script type="text/javascript">
var a = prompt("Nhap a =");
var b = prompt("\nNhap b =");
if (a==0){
	if(b==0){document.write("PTVSN");}
	else {document.write("PTVN");}
}else{
	var x = -b/a;
	document.write("Phuong trinh co nghiem la ",x);
}
</script>
</body>
</html>


avatar
Trần Văn Lâm [T2008A]
2020-10-17 14:37:01


#b1.html


<!DOCTYPE html>
<html>
<head>
	<title>Giai Phuong Trinh</title>
	<meta charset="utf-8">
</head>
<body>
	<div>
		<div>
			Giai phuong trinh bac nhat ax+b=0
		</div>
		<div>
		   <button onclick="nhapa()">Nhap a</button>
		   <button onclick="nhapb()">Nhap b</button>
		   <button onclick="printresult()">ke qua</button>
		</div>
	</div>
   
	<script type="text/javascript">
		var a,b;
		function nhapa(){
			a = prompt('Nhap a')
		}
		function nhapb(){
			b = prompt('Nhap b')
		}
		function printresult(){
			if (a == 0) {
				if (b == 0) {
					alert('ptvsn')
				}else{
					alert('ptvn')
				}
			}else{
				x = -b/a
				alert(x)
			}
		}
	</script>
</body>
</html>


avatar
vuong huu phu [T2008A]
2020-10-16 14:54:45



<!DOCTYPE html>
<html>
<head>
	<title> bai2</title>
	
</head>
<body>
<meta charset="utf-8">
<script type="text/javascript">
	var a =prompt(" nhập số a ");
	var b =prompt(" nhập số b ");

if(a==0){document.write("pt vo nghiem")};
if(b==0){document.write("pt vo nghiem")};
var x;
if( a>0 && b>0){
x=(-b/a);
	document.write(x);
}	
</script>
</body>
</html>


avatar
nguyễn Sử [T2008A]
2020-10-16 12:09:11


#giaiphuongtrinh.html


<!DOCTYPE html>
<html>
<head>
	<title>Giai phuong trinh bac nhat</title>
</head>
<body>
	<script type="text/javascript">
		var x;
		var a = prompt('a');
		var b = prompt('b');
		
if (a==0) {
	if (b==0) {
		alert ("ptvsn")
	}else {
		alert ("ptvn")
	}
	}else {
		x = (-b/a);
		alert(x)

	}
	
	</script>

</body>
</html>


avatar
hainguyen [T2008A]
2020-10-16 10:15:25


#java1.html


<!DOCTYPE html>
<html>
<head>
	<title>Bot</title>
</head>
<body>
	<script type="text/javascript">
		
			var a,b, x
		a = prompt('Nhap a')
		b = prompt('Nhap b')

		function giai(a,b){
			if(a==0) {
				if (b==0) {
					document.write('PTVSN')
					str =+'PTVSN'
				} else {
					str =+  'PTVN'
				}
			} else {
				x = -b/a;
				document.write('x = ' + x)
				x = eval(x);
			}
		}

		

		giai(a, b)
		
	</script>
</body>
</html>


avatar
Triệu Văn Lăng [T2008A]
2020-10-16 10:04:24


#ptbac1(2004).html


<!DOCTYPE html>
<html>
<head>
	<title>Giai pt bac nhat</title>
</head>
<body>
	<script type="text/javascript">
		var a, b;
		a=prompt("nhap a");
		b=prompt("nhap b");
		var x=(-b/a);
		document.write("x= "+x);
	</script>
</body>
</html>


avatar
Đức Sơn [T2008A]
2020-10-16 09:53:44


#js3.html


<!DOCTYPE html>
<html>
<head>
	<title>JS</title>
</head>
<body>
   <script type="text/javascript">
   	var a=prompt('Nhap gia tri a:')
   	var b=prompt('Nhap gia tri b:')
   	if (a==0) {
   		if (b==0) {
   			alert ("Phuong trinh vo so nghiem")
   		} else {
            alert ("Phuong trinh vo nghiem")
   		}
   	} else {
   		x = -b/a 
   		alert(x)
   	}
   </script>
</body>
</html>


avatar
Nguyễn Hữu Hiếu [T2008A]
2020-10-16 08:52:54


#1605.html


<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>
	<script type="text/javascript">
		var a = prompt("Nhap a = ", 0);
		var b = prompt("Nhap a = ", 0);
		var x = -b/a;
		
		if (a == 0) {
			if (b == 0) {
				document.write("PT vo so nghiem");
			}
			else {
				document.write("PT vo nghiem");
			}	
		}
		else {
			document.write(x);
		}	
		
	</script>
</body>
</html>


avatar
Nguyễn Tiến Đạt [T2008A]
2020-10-16 08:43:58


#phuongtrinhbac1.html


<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Giải phương trình bậc 1</title>
</head>
<body style="font-size: 30px;">
	<script>
		alert('Bài toán giải phương trình bậc nhất!!!');
		a=prompt('Nhập a:');
		b=prompt('Nhập b:');
		if(a==0){
			if(b==0){
				document.write('Phương trình vô số nghiệm!!!')
			}
			else{
				document.write('Phương trình vô nghiệm!!!')
			}
		}
		else{
			x=-b/a
			document.write('Phương trình có nghiệm là '+x)
		}
	</script>
</body>
</html>