標題:
練習八、閏年判斷加強版之占卜程式
[打印本頁]
作者:
游東祥
時間:
2014-7-18 14:32
標題:
練習八、閏年判斷加強版之占卜程式
閏年判斷加強版占卜程式
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>我的占卜小程式</title>
</head>
<body>
<script type="text/javascript">
function inputRange(msg,min,max) {
var value = parseInt(prompt(msg));
return Math.min(max, Math.max(min, value));
}
var y = inputRange("請輸入您的出生年:", 1900, 2014);
var m = inputRange("請輸入您的出生月:", 1, 12);
// 閏年判斷
var isLeapYear = (y % 400 == 0) || (y % 4 == 0 && y % 100 != 0);
// 每月份總日數陣列
var maxDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
maxDays[1] = (isLeapYear) ? 29 : 28;
var d = inputRange("請輸入您的出生日:", 1, maxDays[m - 1]);
alert("您輸入的日期是:" + y + "/" + m + "/" + d)
var r = ((y + m) * d) % 3;
var a = ["吉", "一般", "凶"]
alert(a[r]);
</script>
</body>
</html>
複製代碼
作者:
李允軒
時間:
2014-7-18 14:32
<!DOCTYPE html>
<html>
<head>
<meta charset "UTF-8">
<title>我的占卜小程式</title>
</head>
<body>
<script type="text/javascript">
function inputRange(msg,min,max) {
var value = parseInt(prompt(msg));
return Math.min(max,Math.max(min,value));
}
var y = inputRange("請輸入您的出生年:", 1900, 2014);
var m = inputRange("請輸入您的出生月:",1, 12);
var isLeapYear = false;
if(y % 400 == 0)
{
isLeapYear = true;
}
else if(y % 4 == 0 && y % 100 != 0)
{
isLeapYear = true;
}
var maxdays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
maxdays[1] = (isLeapYear)? 29 : 28;
var d = inputRange("請輸入您的出生日:",1, maxdays[m - 1]);
alert("您輸入的日期是:" + y + "/" + m + "/" + d)
var r = ((y + m) * d) % 3;
var a = ["吉", "一般", "凶"]
alert(a[r]);
</script>
</body>
</html>
複製代碼
作者:
陳威臣
時間:
2014-7-18 14:32
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>占卜</title>
</head>
<body>
<script type="text/javascript">
var input;
function inputRarge (msg,min,max)
{
var yoho=parseInt(prompt(msg))
return Math.min(max, Math.max (min, yoho) );
}
var y=inputRarge("出生年" , 1990 , 2014);
var m=inputRarge("出生月" , 1 , 12);
var isLeapYer=(y%400==0)||(y%4==0&&y%100!=0);
var t=[31,28,31,30,31,30,31,31,30,31,30]
t[1]=(isLeapYer)?29:28
var p=inputRarge("出生日" , 1 , 31);
alert("輸入的是:" + y + "/" + m + "/" + p )
var result=((y+m)*p)%3;
var fufu=["Very Good","一般","凶"]
alert(fufu[result])
</script>
</body>
</html>
複製代碼
作者:
張彥承
時間:
2014-7-18 14:32
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>我的占卜小程式</title>
</head>
<body>
<script type="text/javascript">
function inputRange(msg,min,max) {
var value = parseInt(prompt(msg));
return Math.min(max,Math.max(min,value));
}
var y = inputRange("請輸入您的出生年:", 1900, 2014);
var m = inputRange("請輸入您的出生月:",1, 12);
var d = inputRange("請輸入您的出生日:",1, 31);
var isLeapyear=false;
if(y%400==0)
{
isLeapyear=true;
}else if(y%4==0 && y% 100!=0 )
{
isLeapyear=true;
}
var maxDays=[31,28,31,30,31,30,31,31,30,31,30,31];
maxDays[1]=(isLeapyear)?29:28;
alert("您輸入的日期是:" + y + "/" + m + "/" + maxDays[m-1]);
var r = ((y + m) * d) % 3;
var a = ["吉", "一般", "凶"]
alert(a[r]);
</script>
</body>
</html>
複製代碼
作者:
劉泳鱔
時間:
2014-7-18 14:33
<!DOCTYPE htyml>
<html>
<head>
<meta charset="UTF-8">
<title>我的占卜程式</title>
</head>
<body>
<script type="text/javascript">
var y=parseInt(prompt("請輸入出生年"));
var m=parseInt(prompt("請輸入出生月"));
var isLeapYear=false;
if(y%400==0)
{
isLeapYear=true;
}else if(y%4==100 && y%100!=0)
{
isLeapYear=true;
}
var maxDays=[31,28,31,30,31,30,31,31,30,31,30,31];
maxDays[1]=(isLeapYear)?29:28;
var d=parseInt(prompt("請輸入出生日"));
alert("你的出生日期是: "+y+"/"+m+"/"+d+maxDays[m-1]);
var result=((y+m)*d)%3;
if(result==0)
{
alert("吉");
}else if(result==1)
{
alert("一般");
}else
{
alert("凶");
}
</script>
</body>
</html>
複製代碼
作者:
陳品諨
時間:
2014-7-18 14:33
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>我的占卜小程式</title>
</head>
<body>
<script type="text/javascript">
function inputRange(msg,min,max) {
var value = parseInt(prompt(msg));
return Math.min(max,Math.max(min,value));
}
var isLeapyear= false
var y = inputRange("請輸入您的出生年:", 1900, 2014);
var m = inputRange("請輸入您的出生月:",1, 12);
if (y%400==0)
{
isLeapyear=true;
}
else if (y%4==0 &&y%100!=0)
{
isLeapyear=true;
}
var maxdays=[31,28,31,30,31,30,31,31,30,31,30,31];
maxdays[1]=(isLeapyear)?29:28;
var d = inputRange("請輸入您的出生日:",1, 31);
alert("您輸入的日期是:" + y + "/" + m + "/" + d)
var r = ((y + m) * d) % 3;
var a = ["吉", "一般", "凶"]
alert(a[r]);
</script>
</body>
</html>
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2