From 773540b9ec99020ff8e0f1d3d4600770fe6ec52a Mon Sep 17 00:00:00 2001 From: Vaibhav Prajapati Date: Thu, 6 Oct 2022 12:14:47 +0530 Subject: [PATCH 1/2] Added JAVA code to convert Number to Words --- Number2Words/n2w.class | Bin 0 -> 2274 bytes Number2Words/n2w.java | 84 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 Number2Words/n2w.class create mode 100644 Number2Words/n2w.java diff --git a/Number2Words/n2w.class b/Number2Words/n2w.class new file mode 100644 index 0000000000000000000000000000000000000000..a8e0932b8a2a06c99bbf30a0376fc74484b23d52 GIT binary patch literal 2274 zcmaJ?OK=ob6g@BV>CR+AhQoHCgagY@wlTNx*Fa?A>+=D{VU2ShE<~cT@If%%a5W5m5bt#cZY3 zE^0DjsP(ZG6V^ni?54uNp~BOt4T6X2Ub+Pd1R(pV$sEGHC&OU2Kda(^lw~l=hnVyP zyF~Gb6d8x&fUJs9C=SVhGGVEV$n<52l%J&>;8Q+Iqe8{byJlX+v7i>G;u&^6ft7eZ zi5yPQV%jKH%;5=vrqlQQGx z0ZXE*%y*l-R!n-o;yk_AE z95BXx$7O<-7WTes7=j++VHZtr4d+aY})lfGTjcZc-d8Tj@FzWsskp1}7BjtOm_K6E#FfWRT9WhKH> z65*gkI84j9_B2OD8|0{J!yIe1XY{^kER3$p=+EhWF;>`q6UXN<3f#b{bo44Tu5D?L zbf>oGJ7u+zo_J%t{nj=7oQ{8qUG0r=xpf(>fnBI|&SNY9;M(d~I-b9`a9-S*!^Nr- z(VMFxr|9YK(?se~=(M#_34&F3V^^^%w4g!tAhI%<>VA*XsC)w*RolzeimI6sg?n>%wn-|~1XQ?!O_U@2MWK*64J1d3L})}U*;9vgsK*H`$LIV` z{em_4gDZbwJ^ta_REK7f#0Js8C#eZ7BFzV>1)D`L+QbpQJ|pN5qkMI2J~(I5C1$Zh zT)<9oiBHRA^owiQE#|OC%ww 4) { + System.out.println( + "Length more than 4 is not supported"); + return; + } + String[] single_digits = new String[] { + "zero", "one", "two", "three", "four", + "five", "six", "seven", "eight", "nine" + }; + String[] two_digits = new String[] { + "", "ten", "eleven", "twelve", + "thirteen", "fourteen", "fifteen", "sixteen", + "seventeen", "eighteen", "nineteen" + }; + + String[] tens_multiple = new String[] { + "", "", "twenty", "thirty", "forty", + "fifty", "sixty", "seventy", "eighty", "ninety" + }; + + String[] tens_power + = new String[] { "hundred", "thousand" }; + System.out.print(String.valueOf(num) + ": "); + if (len == 1) { + System.out.println(single_digits[num[0] - '0']); + return; + } + int x = 0; + while (x < num.length) { + if (len >= 3) { + if (num[x] - '0' != 0) { + System.out.print( + single_digits[num[x] - '0'] + " "); + System.out.print(tens_power[len - 3] + + " "); + } + --len; + } + else { + if (num[x] - '0' == 1) { + int sum + = num[x] - '0' + num[x + 1] - '0'; + System.out.println(two_digits[sum]); + return; + } + else if (num[x] - '0' == 2 + && num[x + 1] - '0' == 0) { + System.out.println("twenty"); + return; + } + else { + int i = (num[x] - '0'); + if (i > 0) + System.out.print(tens_multiple[i] + + " "); + else + System.out.print(""); + ++x; + if (num[x] - '0' != 0) + System.out.println( + single_digits[num[x] - '0']); + } + } + ++x; + } + } + public static void main(String[] args) + { + Scanner sc = new Scanner(System.in); + String s; + System.out.println("Enter Number ->> "); + s = sc.nextLine(); + convert_to_words(s.toCharArray()); + } +} \ No newline at end of file From f8c125455faafd10f7f18e3724747683a70a799c Mon Sep 17 00:00:00 2001 From: Vaibhav Prajapati Date: Fri, 7 Oct 2022 00:12:19 +0530 Subject: [PATCH 2/2] Added Number 2 Words/Removed .class file --- Number2Words/n2w.class | Bin 2274 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Number2Words/n2w.class diff --git a/Number2Words/n2w.class b/Number2Words/n2w.class deleted file mode 100644 index a8e0932b8a2a06c99bbf30a0376fc74484b23d52..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2274 zcmaJ?OK=ob6g@BV>CR+AhQoHCgagY@wlTNx*Fa?A>+=D{VU2ShE<~cT@If%%a5W5m5bt#cZY3 zE^0DjsP(ZG6V^ni?54uNp~BOt4T6X2Ub+Pd1R(pV$sEGHC&OU2Kda(^lw~l=hnVyP zyF~Gb6d8x&fUJs9C=SVhGGVEV$n<52l%J&>;8Q+Iqe8{byJlX+v7i>G;u&^6ft7eZ zi5yPQV%jKH%;5=vrqlQQGx z0ZXE*%y*l-R!n-o;yk_AE z95BXx$7O<-7WTes7=j++VHZtr4d+aY})lfGTjcZc-d8Tj@FzWsskp1}7BjtOm_K6E#FfWRT9WhKH> z65*gkI84j9_B2OD8|0{J!yIe1XY{^kER3$p=+EhWF;>`q6UXN<3f#b{bo44Tu5D?L zbf>oGJ7u+zo_J%t{nj=7oQ{8qUG0r=xpf(>fnBI|&SNY9;M(d~I-b9`a9-S*!^Nr- z(VMFxr|9YK(?se~=(M#_34&F3V^^^%w4g!tAhI%<>VA*XsC)w*RolzeimI6sg?n>%wn-|~1XQ?!O_U@2MWK*64J1d3L})}U*;9vgsK*H`$LIV` z{em_4gDZbwJ^ta_REK7f#0Js8C#eZ7BFzV>1)D`L+QbpQJ|pN5qkMI2J~(I5C1$Zh zT)<9oiBHRA^owiQE#|OC%ww