Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Write the program numbers into words.For example
2345==two thousand three hundred fourty five

Answers were Sorted based on User's Feedback



Write the program numbers into words.For example 2345==two thousand three hundred fourty five..

Answer / sudarshan

word is:=one
word is:=two
word is:=three
word is:=four

Is This Answer Correct ?    3 Yes 3 No

Write the program numbers into words.For example 2345==two thousand three hundred fourty five..

Answer / rajesh babu

public class NumberToWords{
static final String[] Number1 = {""," Hundrad"};
static final String[] Number2 = {"","One","Two",
"Three","Four","Five",
" Six"," Seven", "Eight"," Nine","Ten" };
String number(int number){
String str;
if (number % 100 < 10){
str = Number2[number % 100];
number /= 100;
}
else {
str= Number2[number % 5];
number /= 5;
}
if (number == 0) return str;
return Number2[number] + "hundred" + str;
}
public String convert(int number) {
if (number == 0){
return "zero";
}
String pre = "";
String str1 = "";
int i = 0;
do {
int n = number % 100;
if (n != 0){
String s = number(n);
str1 = s + Number1[i] + str1;
}
i++;
number /= 100;
}
while (number > 0);
return (pre + str1).trim();
}
public static void main(String[] args) {
NumberToWords num = new NumberToWords();
System.out.println("words is :=" + num.convert(1));
System.out.println("words is :=" + num.convert(2));
System.out.println("words is :=" + num.convert(3));
System.out.println("words is :=" + num.convert(4));
}
}

Is This Answer Correct ?    4 Yes 13 No

Post New Answer

More Core Java Interview Questions

What is Session and cookies?Explain in detail with an example?

4 Answers   Accenture, CTS,


why we are calling j2se why not j1se or j3se or j4se..etc is there any reason.. can u please explain it... i shocked in my interview when they asked this question please explain ans

2 Answers   Infosys,


What is the default execution method in java?

0 Answers  


How to change value in arraylist java?

0 Answers  


Does a class inherit the constructors of its superclass in java programming?

0 Answers  


How we can run a jar file through command prompt in java?

0 Answers  


How to perform selection sort in java?

0 Answers  


How to set the Heap size in Java ?

2 Answers   HCL,


Explain the JDB in depth & command line.

0 Answers  


Explain the difference between extends thread vs implements runnable in java?

0 Answers  


In Inheritence concept, i have a static method in super class and i am inheriting that class to one sub class.in that case the static method is inherited to sub class or not????

12 Answers   Accenture,


How to override equals() and hashCode() method in java?

1 Answers   Wipro,


Categories