嗨,我正在开发一个安卓应用程序…与命理学有关..其中我需要计算当前数字的对应值..首先,我将给出如何计算它的信息。在命理学中,每个字母都有自己的值。这些值如下所示。
A-1,B-2,C-3,D-4,E-5,F-6,G-7,H-8,I-9
J-1,K-1,L-3,M-4,N-5,O-6,P-7,Q-8,R-9
S-1,T-2,U-3,V-4,W-5,X-6,Y-7,Z-8
我的问题是,我需要显示一个人从2012年到2022年的当前工作人数。它是这样计算的。假设我的名字叫Jocheved,出生日期是12-02-1988,那么在1988年,我的字母是J,因为这是我名字的第一个字母,根据上表,J的值是1,所以J在我生活中的影响是1年,即从1988到1989,我的下一个字母是O,它的值是6。所以O的影响将持续6年,即从1989到1995,从1996年开始,C的影响将开始,一旦字母结束,它将重新开始,在我的情况下,即J。
在我的程序中,我需要显示2012年到2022年的有效人员信函。我开发了一个程序,我可以显示从我的道布到2022年的价值,但我只需要从2012年开始。这意味着它应该像2012 -X 2013 -X那样。我在下面给出我的代码..如果有人能帮上忙..。请帮帮忙
tv23.setText(getValueCycle2(2022));
private CharSequence getValueCycle2(int endYear) {
// TODO Auto-generated method stub
int c = 0;
String out = "FName\n\n";
char[] cycle = getLetterCycle();
if(birthYear + 1 > endYear)
{
return "";
}
for (int i = birthYear + 1; i <= endYear ; i++)
{
out += cycle[c] + "\n";
Log.v(TAG, "i - " + i + " : c - " + c + " : cycle(c) - " + cycle[c]);
c++;
if (c == cycle.length)
{
c = 0;
}
}
return out;
}
private char[] getLetterCycle() {
// TODO Auto-generated method stub
int value;
char ch;
String str = "";
for (int i = 0; i < fName.length(); i++)
{
ch = fName.charAt(i);
if (ch >= 'A' && ch <= 'Z')
{
value = letterValue(ch);
for (int j = 0; j < value; j++)
{
str += ch;
}
}
}
return str.toCharArray();
}
private int letterValue(char c) {
// TODO Auto-generated method stub
if (c < 65 || c > 90)
{
return 0;
}
int v = (c - 64) % 9;
return v == 0 ? 9 : v;
}
发布于 2014-05-27 15:07:42
我不确定我是否理解了你的问题。如果你只想打印2012年的输出,你只需要两件事:
将方法签名更改为‘
private static CharSequence getValueCycle2(int startYear, int endYear)
将Log.v更改为
if (i >= startYear) {
Log.v(TAG, "i - " + i + " : c - " + c + " : cycle(c) - " + cycle[c]);
}
将该方法调用为
tv23.setText(getValueCycle2(2012,2022));
还是我错过了什么?
https://stackoverflow.com/questions/23882883
复制相似问题