一个java小程序是我根据-----

【在线测试】测测你上辈子是什么人?

shirleyzjm

六品道台









加入于: 14Nov02

帖子: 443

来自:france

发表: 2003-05-16 on 21:37

--------------------------------------------------------------------------------

你的公元出生年月日加起来

例如:1975.2.20出生的人就是1+9+7+5+0+2+2+0=26

这时出来的数字如果是一位数以上的话再相加(如果相加之后还是一位数以上的话.就再相加.直到变成一位数)

例如:先前出来的是26 那就是2+6=8

或:3+7=10=1+0=1

将出来的数字对照下面的表就可以得知你上辈子是什么噜

1 代表你上辈子是皇宫贵族

2 代表你上辈子是非汉人(特方面的习惯会跟身边的人不太一样)

3 代表你上辈子是有钱人

4 代表你上辈子是读书人

5 表示你上辈子是武将

6 表示你上辈子是非人类

7 表示你上辈子是三级贫户

8 表示你上辈子是优(特征:肢体动作丰富.具表演天分)

9 表示你上辈子是出家人

是阳历的数字,无里头,请别太当真,玩玩而已,祝大家开心!!:))写的。

/*

*This version I wrote didn’t include error checkings, no catching exceptions and no java doc. Coding is not very

efficient I hope next time I can make it much more better. Any question contact: qq:47263574.

/

//the type package is download from http://www.cs.yorku.ca/java/bin/type/type.jar owned by:

//save the download in the following directory: j2sdk1.4.1_??jrelibext under the name type.jar

import type.lang.
;

import java.util.
;

public class Shangbeizi {

public static void main(String[] args) {

char c = ‘y’;

while (c == ‘y’)

{

IO.println(“ÏëÖªµÀÄãÉϱ²×Ó¸ÉʲôµÄÂð£¬ÇëÊäÈëÄãµÄ³öÉúÄêÔÂÈÕ¡£ÀýÈç:1923.12.12;ÓþäºÅ・Ö¸îÄêÔÂÈÕ”);

String birthday = IO.readLine();//get an input from the user; I don’t know how you guys get standard input.

StringTokenizer st = new StringTokenizer(birthday, “.”);

int year = Integer.parseInt(st.nextToken());

int month = Integer.parseInt(st.nextToken());

int date = Integer.parseInt(st.nextToken());



int sum = year(year) + DateAndMonth(month,date);

sum = total(sum);

//case selection

switch (sum){

case (1):

IO.println(“你上辈子是皇宫贵族”);

break;

case (2):

IO.println(“你上辈子是非汉人(特方面的习惯会跟身边的人不太一样)”);

break;

case (3):

IO.println(“你上辈子是有钱人”);

break;

case (4):

IO.println(“你上辈子是读书人”);

break;

case (5):

IO.println(“你上辈子是武将”);

break;

case (6):

IO.println(“你上辈子是非人类”);

break;

case (7):

IO.println(“你上辈子是三级贫户”);

break;

case (8):

IO.println(“你上辈子是优(特征:肢体动作丰富.具表演天分”)



break;

default :

IO.println(“±íʾÄãÉϱ²×ÓÊdzö¼ÒÈË”);

break;

}

IO.println(“你上辈子是出家人”);

c = Character.toLowerCase(IO.readChar());

}

}

private static int year(int num)

{

int toBeReturned = 0;

int progression = 1000;

for ( int i=0; i<4; i++)

{

toBeReturned += num/progression;

num = num%progression;

progression /= 10;

}

return toBeReturned;

}

private static int DateAndMonth(int date, int month)

{

int toReturn;

if(date >= 10 && month >= 10)

toReturn = date/10 + date%10 + month/10 + month%10;

else if (date >= 10 && month < 10)

toReturn = date/10 + date % 10 + month;

else if (date < 10 && month >= 10)

toReturn = month/10 + month%10 + date;

else

toReturn = date + month;

return toReturn;

}



private static int total(int sum) {

int temp;

while(sum>=10)

{

temp = sum/10;

sum = sum%10 +temp;

}

return sum;

}

}

/enjoying it, don’t take it serious/







乱码换成"想知道你上辈子作什么吗?请输入你的出生年月日。例如1959.12.12年月日请用 . 隔开







就是一个dot隔开。

了不起啊

谢谢抬举,only a few case selections and some simple calculation.No complex data structure,no efficient algorithm applied.Mabe next time I’ll make a better one for all you guys.