Sample

 Input 3 15012233444 3-4-4 15012233444 3-3-5 12223 2-3  Output Case #1: one five zero one double two three three triple four Case #2: one five zero one double two double three triple four Case #3: one two double two three 

package rounda;

import java.util.Scanner;

public class Problem1 {

public void output(int caseNo,  String res){
System.out.println("Case #"+caseNo+": "+res);

}
public String solve(String number,String formator){
String[] form = formator.split("-");
int beginIndex=0;
String res = "";
for(int i=0;i<form.length;i++){
int n = Integer.parseInt(form[i]);
String part = number.substring(beginIndex, beginIndex+n);

beginIndex +=n;

}
return res.trim();
}
int continuous=1;
char last = number.charAt(0);
String res="";
for(int i=1;i<number.length();i++){
if(number.charAt(i) == last){
continuous++;
continue;
}else{
last = number.charAt(i);
continuous = 1;
}

}
return res.trim();
}
String res ="";
switch(continuous){
case 1:
res+=charToName(last)+" ";
break;
case 2:
res+="double "+charToName(last)+" ";
break;
case 3:
res+="triple "+charToName(last)+" ";
break;
case 4:
break;
case 5:
res+="quintuple "+charToName(last)+" ";
break;
case 6:
res+="sextuple "+charToName(last)+" ";
break;
case 7:
res+="septuple "+charToName(last)+" ";
break;
case 8:
res+="octuple "+charToName(last)+" ";
break;
case 9:
res+="nonuple "+charToName(last)+" ";
break;
case 10:
res+="decuple "+charToName(last)+" ";
break;
default:
for(int k=0;k<continuous;k++)
res+=charToName(last)+" ";
break;
}
return res;
}
public String charToName(char c){
int n = c-'0';
String res = "";
switch(n){
case 0:
res = "zero";
break;
case 1:
res = "one";
break;
case 2:
res = "two";
break;
case 3:
res = "three";
break;
case 4:
res = "four";
break;
case 5:
res = "five";
break;
case 6:
res = "six";
break;
case 7:
res = "seven";
break;
case 8:
res = "eight";
break;
case 9:
res = "nine";
break;
}
return res;
}
public static void main(String[] args) {
Scanner scanner;
Problem1 p = new Problem1();

scanner = new Scanner(System.in);
int T = scanner.nextInt();
int count=T;
while(count-->0){
String number = scanner.next();
String formator = scanner.next();
String result = p.solve(number,formator);
p.output(T-count,   result);
}
}

}