计算丢失号码的数目数目、号码

2023-09-07 02:44:01 作者:以梦为马趁诗酒年华

我在开发Android应用程序,这是一个命理的应用程序。在其中计算该名称的值是做:

一个,J,S - 1结果B,K,T - 2结果C,L,U - 3结果D,M,V - 4结果E,N,W - 5结果F,O,X - 6结果G,P,Y - 7结果H,Q,Z - 8结果I,R - 9

这是每个字母的价值。当用户输入的计算他的价值的名称并显示结果。我公司开发的code计算值。但现在我需要计算丢失号码。例如我的名字叫 ROSHAN 和我的价值是的R - 9,澳 - 6,S - 1,H - 8,A - 1,N - 5 。所以,当我计算所有这些值 9 + 6 + 1 + 8 + 1 + 5 = 30 = 3 + 0 = 3 。所以,我的价值是三。我做了code表示。

我开发code为寻找失踪号码的数量就像我的名字失踪数字是2,3,4,7如此缺少数字的4个数谁能帮助我?我所提供的code到目前为止,我已经开发了。

Mainactivity.java

 长sum70 = 0;长sum80 = 0;长sum90 = 0sum70 = getsum70(et7.getText()的toString());sum80 = getSum80(et8.getText()的toString());sum90 = getSum90(et9.getText()的toString());私人长期getsum70(字符串文本){  // TODO自动生成方法存根  长sum70 = 0;  的char [] = name70新的char [text.length()];  name70 = text.toCharArray();  的for(int i = 0; I< text.length();我++)  {    sum70 + = value70(name70 [I]);  }  而(sum70> 9)  {    sum70 = findDigitSum70(sum70);  }  返回sum70;}私人长期value70(CHAR一){  // TODO自动生成方法存根  开关(一)  {  案例'A':    返回1;  案例'B':    返回2;  情况下C:    返回3;  案D:    返回4;  案例'E':    返回5;  案例'F':    返回6;  案例'G':    返回7;  案例'H':    返回8;  案例'我':    返回9;  案例'J':    返回1;  案例'K':    返回2;  案例'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;  默认:    返回0;  }}私人长期findDigitSum70(N久){  // TODO自动生成方法存根  INT sum70 = 0;  而(N!= 0)  {    sum70 + = N%10;    N = N / 10;  }  返回sum70;} 
怎样用Excel 统计重复号码的数量

解决方案

如果您使用int数组,就可以解决这个问题更容易些。

  INT []点= {0,0,0,0,0,0,0,0,0,0}; 

这个数组的索引是每个点。例如,如果你的性格'R',加1点[9]。如果你得到字符O,加1点[6]。

如果你输入你的名字,在数组中的值会是这样。

[0,1,2,3,4,5,6,7,8,9] - 索引

{0,2,0,0,0,1,1,0,1,1} - 值

如果值为0,则该值的指数将丢失号码。而总积分将在每个[*指标值]的总和。

I am developing an Android Application, which is a numerology app. In which the value of calculating the name is doing:

A, J, S – 1 B, K, T – 2 C, L, U – 3 D, M, V – 4 E, N, W – 5 F, O, X – 6 G, P, Y – 7 H, Q, Z – 8 I, R – 9.

This is the value of each letter. When user enter the name his value is calculated and display the result. I developed the code for calculating the value. But now I need to calculate the missing numbers. For example my name is ROSHAN and my value is R - 9, O - 6, S - 1, H - 8, A - 1, N - 5. So when I calculate all these values 9+6+1+8+1+5 = 30 = 3+ 0 = 3. So my value is three. I did the code for that.

I am developing code for the finding the number of missing numbers like in my name missing numbers is 2,3,4,7 so the number of missing numbers in 4. Can anyone help me? I have provided the code I have developed so far.

Mainactivity.java

long sum70 = 0;
long sum80 = 0;
long sum90 = 0
sum70 = getsum70(et7.getText().toString());
sum80 = getSum80(et8.getText().toString());
sum90 = getSum90(et9.getText().toString());
private long getsum70(String text) {
  // TODO Auto-generated method stub
  long sum70 = 0;
  char[] name70 = new char[text.length()];

  name70 = text.toCharArray();

  for(int i=0; i<text.length(); i++)
  {
    sum70 += value70( name70[i] );
  }

  while (sum70>9 )
  {                  
    sum70 = findDigitSum70(sum70);        
  }
  return sum70;
}


private long value70(char a) {
  // TODO Auto-generated method stub
  switch(a)
  {
  case 'A': 
    return 1;    
  case 'B':
    return 2;
  case 'C':
    return 3;
  case 'D':
    return 4;
  case 'E':
    return 5;
  case 'F':
    return 6;
  case 'G':
    return 7;
  case 'H':
    return 8;
  case 'I':
    return 9;
  case 'J':
    return 1;
  case 'K':
    return 2;
  case 'L':
    return 3;
  case 'M':
    return 4;
  case 'N':
    return 5;
  case 'O':
    return 6;
  case 'P':
    return 7;
  case 'Q':
    return 8;
  case 'R':
    return 9;
  case 'S':
    return 1;          
  case 'T':
    return 2;
  case 'U':
    return 3;
  case 'V':
    return 4;
  case 'W':
    return 5;
  case 'X':
    return 6;
  case 'Y':
    return 7;
  case 'Z':
    return 8;
  default:         
    return 0;

  }
}

private long findDigitSum70(long n) {
  // TODO Auto-generated method stub
  int sum70=0;
  while (n != 0) 
  {
    sum70 += n % 10;
    n = n / 10;
  }
  return sum70;
}

解决方案

If you use int array, you can solve this problem more easy.

int[] points = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

This array's index is each point. For example, If you get character 'R', add 1 to points[9]. If you get character 'O', add 1 to points[6].

If you enter your name, the values in array will be like this.

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - index

{0, 2, 0, 0, 0, 1, 1, 0, 1, 1} - value

If value is 0, that value's index will missing number. And total points will be sum of each [index * value].