peri hokiperihokiclarustologisticsrimashaop.compola taktis menang gates of olympus x1000 perihokipemain perihoki bongkar trik jepep starlight princess x1000perihoki beri panduan lengkap bermain mahjong ways 2 pgsofttips cara penghasil uang pgsoft mahjong ways 2 perihokimahjong wins 3 perihoki memberikan penggali terbesarfenomena gates of olympus buka peluang besar bagi duta76cara dapat pola emas rahasia di duta7 wild west goldtrik menang pgsoft mahjong ways 2 modal receh maxwin duta76duta76 main pgsoft mahjong ways 2 di sela istirahatscatter hitam mahjong wins 3 spin pasti jepe duta76pola petir tersembunyi gates of olympus perihokipgsoft perkuat mahjong ways 2 di akun perihokiperihoki beri pola jitu mahjong wins 3 auto maxwin5 scatter jackpot driver ojolstrategi satpam scatter mahjongstrategi menang mahjong abc1131scatter emas pabrik wonosobomodal tipis scatter jadi cuanrtp mahjong ways supir menanginsting kuat bermain mahjong waysmengungkap keunggulan mahjong waysserunya mahjong bermodal kecil untung melimpahstrategi terbaik untuk menang mahjongterus main terus gacormenang banyak dengan scatter mahjong ways1menggali kehebatan mahjong winsrahasia nurul di mahjong waysstrategi mahjong yang mengubah permainan andateknik menang mahjong ways yang efektif
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 282
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_set_cookie_params(): Cannot change session cookie parameters when headers already sent
Filename: Session/Session.php
Line Number: 294
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 304
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 314
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 315
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 316
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 317
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 375
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: drivers/Session_files_driver.php
Line Number: 108
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_set_save_handler(): Cannot change save handler when headers already sent
Filename: Session/Session.php
Line Number: 110
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_start(): Cannot start session when headers already sent
Filename: Session/Session.php
Line Number: 143
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
PHP - Xếp hạng năng lực của học sinh cuối năm
LÝ THUYẾT
XỬ LÝ FORM
BÀI TẬP
CÁC CHỦ ĐỀ
BÀI MỚI NHẤT
PHP - Xếp hạng năng lực của học sinh cuối năm
DOWNLOAD
DEMO
Một trường trung học phổ thông muốn viết chương trình kiểm tra năng lực của học sinh để xét học lực, trường có tổng cộng 5 môn như sau:
- Toán
- Lý
- Hóa
- Tiếng Anh
- Văn
- Lích Sử
Điểm trung bình được tính dựa vào tổng của 6 môn và chia cho 6, và sẽ xếp loại dựa vào yêu cầu sau:
- Điểm trung bình bé hơn 5 là học sinh yếu
- Điểm trung bình trong khoảng 5 -> 6,4 là học sinh trung bình
- Điểm trung bình trong khoảng 6,5 -> 7,9 là học sinh khá
- Điểm trung bình lớn hơn 7,9 là học sinh giỏi
Nếu một trong 6 môn dưới 4 điểm thì xếp loại yếu. Lưu ý là phải kiẻm tra thang điểm của mỗi môn phải nằm trong khoảng từ 0 -> 10.
Bài giải
-------------------- ######## --------------------
Công thức của đề bài rất rõ ràng rồi, bây giờ ta chỉ code thôi ;)

Bài viết này được đăng tại freetuts.net, không được copy dưới mọi hình thức.
// Bạn tự thay thế điểm để test nhes
$toan = 6;
$ly = 4;
$hoa = 6;
$anhvan = 7;
$van = 10;
$lichsu = 9;
// Kiểm tra thang điểm đúng hay sai
if ($toan < 0 || $toan > 10){
echo 'Điểm môn Toán phải từ 0 -> 10';
}
else if ($ly < 0 || $ly > 10){
echo 'Điểm môn Lý phải từ 0 -> 10';
}
else if ($hoa < 0 || $hoa > 10){
echo 'Điểm môn Hóa phải từ 0 -> 10';
}
else if ($anhvan < 0 || $anhvan > 10){
echo 'Điểm môn Anh Văn phải từ 0 -> 10';
}
else if ($van < 0 || $van > 10){
echo 'Điểm môn Văn phải từ 0 -> 10';
}
else if ($lichsu < 0 || $lichsu > 10){
echo 'Điểm môn Lịch Sử phải từ 0 -> 10';
}
else if ($anhvan < 0 || $anhvan > 10){
echo 'Điểm môn Anh Văn phải từ 0 -> 10';
}
else if ($toan <= 4 || $ly <= 4 || $hoa <= 4 || $anhvan <= 4 || $van <= 4 || $lichsu <= 4){
echo 'Xếp loại yếu';
}
else {
$diemTrungBinh = ($toan + $ly + $hoa + $anhvan + $van + $lichsu) / 6;
if ($diemTrungBinh < 5){
echo "Xếp loại yếu";
}
else if ($diemTrungBinh >= 5 && $diemTrungBinh < 6.5){
echo "Xếp loại trung bình";
}
else if ($diemTrungBinh >= 6.5 && $diemTrungBinh < 7){
echo "Xếp loại khá";
}
else {
echo "Xếp loại giỏi";
}
}
Bạn có thể tham khảo chương trình kết hợp với form.
<!DOCTYPE html>
<html>
<head>
<title>Freetuts.net</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<?php
if (isset($_POST['cal']))
{
// Bạn tự thay thế điểm để test nhes
$toan = $_POST['toan'];
$ly = $_POST['ly'];
$hoa = $_POST['hoa'];
$anhvan = $_POST['anhvan'];
$van = $_POST['van'];
$lichsu = $_POST['lichsu'];
// Kiểm tra thang điểm đúng hay sai
if ($toan < 0 || $toan > 10){
echo 'Điểm môn Toán phải từ 0 -> 10';
}
else if ($ly < 0 || $ly > 10){
echo 'Điểm môn Lý phải từ 0 -> 10';
}
else if ($hoa < 0 || $hoa > 10){
echo 'Điểm môn Hóa phải từ 0 -> 10';
}
else if ($anhvan < 0 || $anhvan > 10){
echo 'Điểm môn Anh Văn phải từ 0 -> 10';
}
else if ($van < 0 || $van > 10){
echo 'Điểm môn Văn phải từ 0 -> 10';
}
else if ($lichsu < 0 || $lichsu > 10){
echo 'Điểm môn Lịch Sử phải từ 0 -> 10';
}
else if ($anhvan < 0 || $anhvan > 10){
echo 'Điểm môn Anh Văn phải từ 0 -> 10';
}
else if ($toan <= 4 || $ly <= 4 || $hoa <= 4 || $anhvan <= 4 || $van <= 4 || $lichsu <= 4){
echo 'Xếp loại yếu';
}
else {
$diemTrungBinh = ($toan + $ly + $hoa + $anhvan + $van + $lichsu) / 6;
if ($diemTrungBinh < 5){
echo "Xếp loại yếu";
}
else if ($diemTrungBinh >= 5 && $diemTrungBinh < 6.5){
echo "Xếp loại trung bình";
}
else if ($diemTrungBinh >= 6.5 && $diemTrungBinh < 7){
echo "Xếp loại khá";
}
else {
echo "Xếp loại giỏi";
}
}
}
?>
<div>
<form method="post" action="">
Toán <input type="text" name="toan" value=""/> <br/>
Lý <input type="text" name="ly" value=""/> <br/>
Hóa <input type="text" name="hoa" value=""/> <br/>
Tiếng Anh <input type="text" name="anhvan" value=""/> <br/>
Văn <input type="text" name="van" value=""/> <br/>
Lịch Sử <input type="text" name="lichsu" value=""/> <br/>
<input type="submit" name="cal" value="Kiểm tra"/>
</form>
</div>
</body>
</html>
Câu hỏi thường gặp liên quan:
Cùng chuyên mục: