Java Program to convert number to words | Java Program
Вставка
- Опубліковано 18 жов 2024
- Java Program to convert number to words | Java Program
I think i tried to explain it well enough, if you still have any problems comment or dm!
#java #numbertowords #numberwords
Thanks for watching our video.
Do subscribe.❤💕
Try solving on your own!
Program : drive.google.c...
Check our playlist : • Isc Java Programs
If you need any help, isc, java, just something , dm me !
/ chandraguptaroy
____
Camera : Samsung Galaxy M30
Mic: Boya BYM1 - www.amazon.in/...
Laptop :Acer Aspire 5 i7 10th Gen
Tripod :Tygot Adjustable -www.amazon.in/...
Audio recorder: play.google.co...
Screen Recorder : obs studio
VideoEditor :Adobe Suit
Audio from :
ncs ncsmusic.com/
youtube audio library /Mirror Mirror - Diamond Ortiz
Stock Videos /Photos (if used):
Pexel :www.pexels.com/
Pixabay : www.pexels.com/
Videov : www.videvo.net/
Hey can u upload the code for thousand, ten thousand and lakh
@@theeducationvalley ok say the formula for it for ten thousands
@@mdarshath18 I'll solve and upload tutorial to this program soon, there are too many requests now. 👍
Tutorial will be out soon!
UPTO 5 Digits:
import java.util.*;
class Advance_Number2Words
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
System.out.println("Enter a Number till 5-digits
");
int n=in.nextInt();
String wrd=String.valueOf(n);
int l=wrd.length(); //for length of number.
String z="",zz="";
int i=0,c=0,nn=0,nnn=0,zzc=0;
for( i=l-1; i>=0;i--) //backward for loop iterating from unit place to thousand.
{
char cc=wrd.charAt(i);
c=Integer.valueOf(String.valueOf(cc)); //current digit.
if(i>0) //for combating double number words like thirteen, nineteen etc...
{
zz=wrd.substring(i-1,i+1); //substring extracts string from string(.substring(inclusive,exclusive))
zzc=Integer.valueOf(zz); //contain last two digits eg. 1234 and c=3, so zzc=23
}
else
{
zzc=22;
}
//System.out.println(zzc);
//Arrays//
String uw[]={"","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve",
"Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Ninteen"};
String tw[]={"","Ten","Twenty","Thirty","Fourty","Fifty","Sixty","Seventy","Eighty","Ninety"};
//Arrays//
//nnn controls whether it's hunderd or thousand.
//nn controls the number of digits converted and it resets on hundred/thousand.
//z contains the word.
if (nnn==2) //when it reaches
{
if(c!=0)
{z="hundred "+z;}
nn=0;
}
if (nnn==3)
{
z="thousand "+z;
nn=0;
}
// Main
if(zzc
Here's the advanced code with thousand, lakh , crore etc... ua-cam.com/video/XgL5RvgsQKI/v-deo.html
If you are curious to have perfect code, here it is: ua-cam.com/video/XgL5RvgsQKI/v-deo.html.
Enjoy!
0:00 :Ques
0:20 :Intro
0:40 :Starts
1:20 :Input a Sentence
1:52 :Check for 3 digit number
2:48 :What's the first step
2:59 :Unit Place
3:19 :Tenth Place
4:11 :Hundredths place
4:53 :First step for printing
5:39 :[ Leave the first place of array empty ]
6:40 :Printing 1st Part [
Best explanation in the entire youtube, Thanks bhaiya.
no problem
In else loop, can't we use the while loop ???? Rather than writing so many linesss??
There can be many ways of writing one program, you can leave your solution in the comments of you find a better one. : )
Simplest explanantion, Thanks!
that quote after introduction
Really an Amazing talent but please improve the way of explaining and reduce the background music ...
Yes yes
does this code also work for negative numbers?
No, I never thought of that...!
what if in an dynamic input
Inputs
1.2456
2.654
3.22
What process for up to 1million number to word?
Watch the other video on the channel... : )
Sir can you build a vidio on inheritance using program
Sure! I passed out this year..... i'm making video on all the programs that we did. Where have you all reached now? Inheritance ?
Hey bro...I need your help what if I want to print number to string 0 - 99999
ua-cam.com/video/XgL5RvgsQKI/v-deo.html
Is it possible to execute in eclipse
Yeah, it can be executed in any IDE. Search Google, how to do that...
thank you & super
211?
ua-cam.com/video/XgL5RvgsQKI/v-deo.html
I think there is a mistake in code bro that is
For 110 to 119 it prints one hundred one or two so on
And 120,130.., it prints one hundred twenty zero, one hundred thirty zero..,
super bro
why in uw and tw first column is vacant, why is it so?
It is to make the program simpler.
Position of an array starts at 0
When we leave the first column vacant.
The word for 1 comes at the 1st position of the array.
@@theeducationvalley thank you sir!
Sir, i want to learn programming and coding, can you please suggest how should i prepare myself for all of this ? Can you suggest me pathways to follow for this . I have started coding in java , i have some basic knowledge in c and python but still i sucks at tech code questions. I have to prepare myself in coming 2 months . Can you help please?
Bad naming system, but good job!
😂 Thanks anyway!
Can you type the code its super blurred
Link is in description bro: drive.google.com/drive/u/0/mobile/folders/1I3ddclu9Svd9EbqENGaQhNcSWK301FtH?usp=sharing
Why is that music in background
beautiful explanation
it gives 2 errors.
1) if you enter digits like 100,200,300....
2) if you enter digits which contain numbers one to twenty in them ex ; 412,519,213 etc....
Yeah, this program isn't completely right.
To be exactly right. It will add too much complexity. I have made a new video which returns the right answer.
But, I don't think it's good for school level exams.
Let me know if you find a better and simple solution. : )
Tnx thala 🔥🔥
Thanks 👍
No problem 👍
Thanks man it helped!
Glad to hear it!
Can you edit the code to cater for decimal numbers eg. $34557889.56
@@theeducationvalley you have not done it yet
What do you exactly want in that question? Does it need to print with dollars and cents? Give me an example
Isi ko three four nine kaise print kare
?
Thank you so much.
You're welcome!
This code doesnt translate the hundreds value well enough, if you put 100 + 1~19, it will display One Hundred One Ten Nine ( 119 )
I'm sorry, Yes, there are problems in this code, a better version of this video is almost ready now.!
Program that displays hundreds value ( 119) and 4 digit value
public class NumToWords {
public static String NumberToWords(int a) {
int onesword,c,tensword,e,f,hundredsword,thousandsword;
onesword=a%10;
c=a/10;
tensword=c%10;
e=a/100;
hundredsword=e%10;
thousandsword = a/1000;
String str = "";
String[] ab = {"","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","ninteen"};
String[] tntotwnty = {"","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","ninteen"};
String[] tens = { "","ten","twenty","thirty","fourty","fifty","sixty","seventy","eighty","ninety"};
String hund = " hundred ";
String thousand =" thousand ";
if(a999)
if(hundredsword==0)
str = ab[thousandsword]+thousand+ab[hundredsword]+tens[tensword]+" "+ab[onesword];
else
str = ab[thousandsword]+thousand+ab[hundredsword]+hund+tens[tensword]+" "+ab[onesword];
return str;
}
public static void main(String[] args) {
System.out.println("Enter any number upto 4 digits");
Scanner s = new Scanner(System.in);
int num = s.nextInt();
System.out.println(NumberToWords(num));
}
}
ua-cam.com/video/XgL5RvgsQKI/v-deo.html This code does not have that issue.
Thanks😊
Welcome 😊
Wrong input, fu*koff, was very user friendly....
lol, sorry
what is your name bro
Chandra Gupta Roy (CGR)
Video was not clear
I hope you find this better... ua-cam.com/video/XgL5RvgsQKI/v-deo.html
try 19
If we give in input 114 .
It will print one hundred ten four.
Yeah, this code was school level so there are some issure, check this one for correct output if curious: ua-cam.com/video/XgL5RvgsQKI/v-deo.html
@@theeducationvalley nah did it myself 6 months ago
School level and sys.out is “fu*koff” ?