/**
*
*/
package com;
/**
* @author Boomiraj
*
*/
public class CountChar {
/**
* @param args
*/
static int count = 0;
public static void main(String[] args) {
onecountCharacter();
}
public static void onecountCharacter(){
String[] ones = {"zero","one","two","three","four","five","six","seven","eight","nine"};
String[] ten = {"ten","eleven","twelve","thriteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
String[] tens = {"twenty","thirty","fourty","fifty","sixty","seventy","eighty","nighty"};
for(int i = 0; i < 100; i++){
// Check whether the number is not greater then ten
if(i<10){
count = count + ones[i].length();
System.out.println(ones[i] + " : " + i + " : " + count);
}
// Check whether the number is not greater than 9 and less than 20
if(i>9 && i<20){
int j = 10;
j = i - j; //
count = count + ten[j].length();
System.out.println(ten[j] + ":" + i + " : " + count);
j++;
}
// Check whether then number is greater then 20
if(i>19){
int k = i/10-2;
int j = i % 10;
if(j == 0){
count = count + tens[k].length();
System.out.println(tens[k] + " : " + count);
} else{
count = count + tens[k].length() + ones[j].length();
System.out.println(tens[k] + ones[j] + ":" + i + " :" + count);
}
}
}
System.out.println(count);
}
}
*
*/
package com;
/**
* @author Boomiraj
*
*/
public class CountChar {
/**
* @param args
*/
static int count = 0;
public static void main(String[] args) {
onecountCharacter();
}
public static void onecountCharacter(){
String[] ones = {"zero","one","two","three","four","five","six","seven","eight","nine"};
String[] ten = {"ten","eleven","twelve","thriteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
String[] tens = {"twenty","thirty","fourty","fifty","sixty","seventy","eighty","nighty"};
for(int i = 0; i < 100; i++){
// Check whether the number is not greater then ten
if(i<10){
count = count + ones[i].length();
System.out.println(ones[i] + " : " + i + " : " + count);
}
// Check whether the number is not greater than 9 and less than 20
if(i>9 && i<20){
int j = 10;
j = i - j; //
count = count + ten[j].length();
System.out.println(ten[j] + ":" + i + " : " + count);
j++;
}
// Check whether then number is greater then 20
if(i>19){
int k = i/10-2;
int j = i % 10;
if(j == 0){
count = count + tens[k].length();
System.out.println(tens[k] + " : " + count);
} else{
count = count + tens[k].length() + ones[j].length();
System.out.println(tens[k] + ones[j] + ":" + i + " :" + count);
}
}
}
System.out.println(count);
}
}