#13989: AC_HAHA


terry90209@gmail.com (Mini)

學校 : 不指定學校
編號 : 78019
來源 : [219.71.215.231]
最後登入時間 :
2018-04-03 22:44:44
d086. 態度之重要的證明 -- 成功電研20th~21st C++ ~最後的競賽~ | From: [219.71.215.231] | 發表日期 : 2018-05-26 00:10

public class D086{
public static void main(String[] args){
java.util.Scanner sc = new java.util.Scanner(System.in);
while(sc.hasNext()){
String num = sc.next();
if(num.equals("0")) break;
new CharAdd(num).print();
}
}
}

class CharAdd{
private char[] charr;

public CharAdd(String s){ charr = s.toUpperCase().toCharArray();}

private int getGrade(){
int sum = 0;
for(int i = 0; i < charr.length; i++){
if((int)charr[i] > 90 || (int)charr[i] < 65) return -1;
else sum += (int)charr[i] - 64;
}
return sum;
}

public void print(){
int sum = getGrade();
if(sum == -1) System.out.println("Fail");
else System.out.println(sum);
}
}

 
ZeroJudge Forum