java 难题

则继续按位相加:4+5=9 compassionate and stern "); break; case : System.out.println(str+ "("+i+")"+" is multi-talented decisive and a bit of a loner "); break; case : System.out.println(str+ "("+i+")"+" is money-oriented eccentric and domestic "); break; case : System.out.println(str+ "("+i+")"+" is spiritual careful and sensual "); break; case : System.out.println(str+ "("+i+")"+" is responsible mercurial and serious "); break; case : System.out.println(str+ "("+i+")"+" is adventurous traditional and fun-loving "); break; case : System.out.println(str+"("+i+")"+ " is practical optimistic and analytical "); break; case : System.out.println(str+ "("+i+")"+" is enthusiastic diplomatic and self-sufficient"); break; case : System.out.println(str+ "("+i+")"+" is supportive independent public class Generating Numbers from Names { public static String getEnter(String message){ String str=""; System.out.println(message+":"); BufferedReader buf=new BufferedReader(new InputStreamReader(System.in)); try { str=buf.readLine(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return str; } public static int getResult(char a) { int result = 0; int i=0; char ch='A'; i=Math.abs(ch-a)+1; if(i>18){ result=i-18; }else if(i>9){ result=i-9; }else{ result=i; } return result; } public static int getStringSumResult(String string){ int sum=0; string=string.toUpperCase(); for(int j=0;j<string.length();j++){ if('A'<=string.charAt(j)&&string.charAt(j)<'Z'){ sum+=getResult(string.charAt(j)); } } return sum; } public static int computeLastResult(int sum){ int lastresult=0; String str=sum+""; while(true){ int temp=0; for(int i=0;i<str.length();i++){ temp+=str.charAt(i)-48; } if(temp<=9){ lastresult=temp; break; }else{ str=temp+""; } } return lastresult; } public static void printResult(){ int i=0; String str=getEnter("please enter name"); i=computeLastResult(getStringSumResult(str)); switch(i){ case 后面是数字一直排下去: System.out.println(str+"("+i+")"+ " is ambitious 如果结果不是一个1-9之间的数字 如输入:Alan Turing1 2 3 4 5 6 7 8 9A B C D E F G H IJ K L M N O P Q RS T U V W X Y Z 则结果为1 + 3 + 1 + 5 + 2 + 3 + 9 + 9 + 5 + 7 = 45 然后根据这个对应关系把每个字母对应的数字累加起来 可以得出名字对应的人是一个什么样的人(有点占卜的味道 输入一个姓名 and global compassionate and stern 9 – is multi-talented decisive and a bit of a loner 8 – is money-oriented eccentric and domestic 7 – is spiritual careful and sensual 6 – is responsible mercurial and serious 5 – is adventurous traditional and fun-loving 4 – is practical optimistic and analytical 3 – is enthusiastic diplomatic and self-sufficient 2 – is supportive independent 根据最后的结果和下面的9种结果 其实逻辑很简单 呵呵)1 – is ambitious and global "); break; } } public static void main(String[] args) { printResult(); } } ||| 用javaSwing实现
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值