跟原版的人品计算器功能相同 不过使用java写的 还改了一些我觉得原版不好的地方 至于是哪里嘛...嘿嘿 自己找吧
(提示:equals方法用于比较两个字符串变量是否相等)

代码如下:

[code lang="java"]
import java.util.*;
public class rp {
public static void main(String[] args){
System.out.println("程序名:人品计算器");
System.out.println("请输入你的姓名:");
Scanner in=new Scanner(System.in);
String name=in.next();
char[] a=name.toCharArray();//将输入的名字转为char类型的数组a
int[] b=new int[a.length];
for(int i=0;i<a.length;i++){
b[i]=a[i];
}//将char数组a转换为int数组b(每个字符对应的Unicode码)
int c=0;//变量c为Unicode码的总和
for(int i=0;i<b.length;i++){
c+=b[i];
}
int score=0;//成绩变量

if(name.equals("小日本")||name.equals("日本")||name.equals("日本鬼子")
||name.equals("日本人")||name.equals("世界上最没人品的人")
||name.equals("史上最贱的人")){

score=-1;

}else if(name.equals("陈宇恒")||name.equals("雷锋")
||name.equals("Yuheng Chan")||name.equals("blog.chenyuheng.cn")
||name.equals("yuheng chan")||name.equals("chenyuheng")
||name.equals("ChenYuheng")||name.equals("chenyuheng.cn")){

score=100;//排除个别的差分数和好分数,欢迎在下面的留言里补充

}else{
score=c%100;//计算成绩
}

String o="";
if(score==0){
o="你一定不是人吧?怎么一点人品都没有?!";
}else if(score>0&&score<=5){
o="算了,跟你没什么人品好谈的...";
}else if(score>5&&score<=10){
o="是我不好...不应该跟你谈人品问题的...";
}else if(score>10&&score<=15){
o="杀过人没有?放过火没有?你应该无恶不做吧?";
}else if(score>15&&score<=20){
o="你貌似应该三岁就偷看隔壁大妈洗澡的吧...";
}else if(score>20&&score<=25){
o="你的人品之低下实在让人惊讶啊...";
}else if(score>25&&score<=30){
o="你的人品太差了。你应该有干坏事的嗜好吧?";
}else if(score>30&&score<35){
o="你的人品真差!肯定经常做偷鸡摸狗的事...";
}else if(score>35&&score<=40){
o="你拥有如此差的人品请经常祈求佛祖保佑你吧...";
}else if(score>40&&score<=45){
o="老实交待..那些论坛上面经常出现的偷拍照是不是你的杰作?";
}else if(score>45&&score<=50){
o="你随地大小便之类的事没少干吧?";
}else if(score>50&&score<55){
o="你的人品太差了..稍不小心就会去干坏事了吧?";
}else if(score>55&&score<=60){
o="你的人品很差了..要时刻克制住做坏事的冲动哦..";
}else if(score>60&&score<=65){
o="你的人品比较差了..要好好的约束自己啊..";
}else if(score>65&&score<=70){
o="你的人品勉勉强强..要自己好自为之..";
}else if(score>70&&score<=75){
o="有你这样的人品算是不错了..";
}else if(score>75&&score<=80){
o="你有较好的人品..继续保持..";
}else if(score>80&&score<=85){
o="你的人品不错..应该一表人才吧?";
}else if(score>85&&score<=90){
o="你的人品真好..做好事应该是你的爱好吧..";
}else if(score>90&&score<=95){
o="你的人品太好了..你就是当代活雷锋啊...";
}else if(score>95&&score<=99){
o="你是世人的榜样!";
}else if(score==100){
o="天啦!你不是人!你是神!!!";
}else if(score<0){
o="你的人品竟然负溢出了...我对你无语..";
}//各种分对应的话

System.out.println("你的姓名:"+name);//输出结果
System.out.println("你的分数:"+score);
System.out.println(o);
}
}
[/code]

点击下载class类文件(rp.class)

标签: Java, 作品

添加新评论