Tuesday, September 22, 2015

program to calculate sum of no. in string

program to calculate sum of no. in string
class String1
{
psvm(String[] args)
{
String str="mra12 job13";
String [] str1=str.split("");
int sum=0;
for(int i=0;i<str1.length;i++)
{
try{
sum+=Integer.parseInt(str1[i]);
}
catch(Exception e){}
}
sopln(sum)
}
}

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete