| <!doctype html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Untitled Document</title> | |
| </head> | |
| <body> | |
| <script type="text/javascript"> | |
| month = parseInt(prompt("Nhập tháng bạn muốn xem: ")); | |
| year = parseInt(prompt("Nhập năm mà bạn muốn xem: ")); | |
| //xuat ket qua | |
| switch(month) | |
| { | |
| case 1: | |
| case 3: | |
| case 5: | |
| case 7: | |
| case 8: | |
| case 10: | |
| case 12: day="31 ngay"; | |
| break; | |
| case 4: | |
| case 6: | |
| case 9: | |
| case 11: ngay="30 ngày"; | |
| break; | |
| case 2: if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) | |
| ngay="29 ngày"; | |
| else | |
| ngay="28 ngày"; | |
| break; | |
| } | |
| document.write("Tháng "+month+" năm "+year+" có "+ngay); | |
| </script> | |
| </body> | |
| </html> |
Trang chủ
→
JavaScript
(JAVASCRIPT) switch - case
0 comments :
Post a Comment