Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
Saturday at 11:44 PM
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
JAVA WADDOOOOOOOO warellaaa
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="SHdinesh" data-source="post: 18368681" data-attributes="member: 522078"><p>package demos;</p><p></p><p>import java.util.Scanner;</p><p>import javax.swing.JOptionPane;</p><p></p><p>class NumberToString {</p><p></p><p> public enum hundreds {</p><p></p><p> OneHundred, TwoHundred, ThreeHundred, FourHundred, FiveHundred, SixHundred, SevenHundred, EightHundred, NineHundred</p><p> }</p><p></p><p> public enum tens {</p><p></p><p> Ten, Twenty, Thirty, Forty, Fifty, Sixty, Seventy, Eighty, Ninety</p><p> }</p><p></p><p> public enum ones {</p><p></p><p> One, Two, Three, Four, Five, Six, Seven, Eight, Nine</p><p> }</p><p></p><p> public enum denom {</p><p></p><p> Thousand, Lakhs, Crores</p><p> }</p><p></p><p> public enum splNums {</p><p></p><p> Ten, Eleven, Twelve, Thirteen, Fourteen, Fifteen, Sixteen, Seventeen, Eighteen, Nineteen</p><p> }</p><p> public static String text = "";</p><p></p><p> public static void main(String[] args) {</p><p> JOptionPane.showMessageDialog(null, " Welcome to my maths app");</p><p> long num = 0;</p><p> System.out.println("input number between one and nine hundred");</p><p> Scanner sc = new Scanner(System.in);</p><p> num = sc.nextInt();</p><p> if (num > 900) {</p><p> JOptionPane.showMessageDialog(null, "Number is greater than 900. Please re-enter your number");</p><p> //NumberToString num1 = new NumberToString();</p><p> } else {</p><p> int rem = 0;</p><p> int i = 0;</p><p> long r = num;</p><p></p><p> long hundreds = r / 100;</p><p> long Tens = (r - hundreds * 100) / 10;</p><p> long Ones = r - (hundreds * 100 + Tens * 10);</p><p></p><p> System.out.print("Hundreds : ");</p><p> for (int h = 0; h < hundreds; h++) {</p><p> System.out.print("o");</p><p> }</p><p> System.out.println("");</p><p></p><p> System.out.print("Tens : ");</p><p> for (int h = 0; h < Tens; h++) {</p><p> System.out.print("o");</p><p> }</p><p> System.out.println("");</p><p></p><p> System.out.print("Ones : ");</p><p> for (int h = 0; h < Ones; h++) {</p><p> System.out.print("o");</p><p> }</p><p> System.out.println("");</p><p> while (num > 0) {</p><p> if (i == 0) {</p><p> rem = (int) (num % 1000);</p><p> printText(rem);</p><p> num = num / 1000;</p><p> i++;</p><p> } else if (num > 0) {</p><p> rem = (int) (num % 100);</p><p> if (rem > 0) {</p><p> text = denom.values()[i - 1] + " " + text;</p><p> }</p><p> printText(rem);</p><p> num = num / 100;</p><p> i++;</p><p> }</p><p> }</p><p> if (i > 0) {</p><p> System.out.println(text);</p><p> } else {</p><p> System.out.println("Zero");</p><p> }</p><p> }</p><p></p><p> }</p><p></p><p> public static void printText(int num) {</p><p> if (!(num > 9 && num < 19)) {</p><p> if (num % 10 > 0) {</p><p> getOnes(num % 10);</p><p> }</p><p></p><p> num = num / 10;</p><p> if (num % 10 > 0) {</p><p> getTens(num % 10);</p><p> }</p><p></p><p> num = num / 10;</p><p> if (num > 0) {</p><p> getHundreds(num);</p><p> }</p><p> } else {</p><p> getSplNums(num % 10);</p><p> }</p><p> }</p><p></p><p> public static void getSplNums(int num) {</p><p> text = splNums.values()[num] + " " + text;</p><p> }</p><p></p><p> public static void getHundreds(int num) {</p><p> text = hundreds.values()[num - 1] + " " + text;</p><p> }</p><p></p><p> public static void getTens(int num) {</p><p> text = tens.values()[num - 1] + " " + text;</p><p> }</p><p></p><p> public static void getOnes(int num) {</p><p> text = ones.values()[num - 1] + " " + text;</p><p> }</p><p>}</p><p></p><p>Now try it. <img src="/styles/default/xenforo/smilies/default/wink.gif" class="smilie" loading="lazy" alt=";)" title="Wink ;)" data-shortname=";)" /></p></blockquote><p></p>
[QUOTE="SHdinesh, post: 18368681, member: 522078"] package demos; import java.util.Scanner; import javax.swing.JOptionPane; class NumberToString { public enum hundreds { OneHundred, TwoHundred, ThreeHundred, FourHundred, FiveHundred, SixHundred, SevenHundred, EightHundred, NineHundred } public enum tens { Ten, Twenty, Thirty, Forty, Fifty, Sixty, Seventy, Eighty, Ninety } public enum ones { One, Two, Three, Four, Five, Six, Seven, Eight, Nine } public enum denom { Thousand, Lakhs, Crores } public enum splNums { Ten, Eleven, Twelve, Thirteen, Fourteen, Fifteen, Sixteen, Seventeen, Eighteen, Nineteen } public static String text = ""; public static void main(String[] args) { JOptionPane.showMessageDialog(null, " Welcome to my maths app"); long num = 0; System.out.println("input number between one and nine hundred"); Scanner sc = new Scanner(System.in); num = sc.nextInt(); if (num > 900) { JOptionPane.showMessageDialog(null, "Number is greater than 900. Please re-enter your number"); //NumberToString num1 = new NumberToString(); } else { int rem = 0; int i = 0; long r = num; long hundreds = r / 100; long Tens = (r - hundreds * 100) / 10; long Ones = r - (hundreds * 100 + Tens * 10); System.out.print("Hundreds : "); for (int h = 0; h < hundreds; h++) { System.out.print("o"); } System.out.println(""); System.out.print("Tens : "); for (int h = 0; h < Tens; h++) { System.out.print("o"); } System.out.println(""); System.out.print("Ones : "); for (int h = 0; h < Ones; h++) { System.out.print("o"); } System.out.println(""); while (num > 0) { if (i == 0) { rem = (int) (num % 1000); printText(rem); num = num / 1000; i++; } else if (num > 0) { rem = (int) (num % 100); if (rem > 0) { text = denom.values()[i - 1] + " " + text; } printText(rem); num = num / 100; i++; } } if (i > 0) { System.out.println(text); } else { System.out.println("Zero"); } } } public static void printText(int num) { if (!(num > 9 && num < 19)) { if (num % 10 > 0) { getOnes(num % 10); } num = num / 10; if (num % 10 > 0) { getTens(num % 10); } num = num / 10; if (num > 0) { getHundreds(num); } } else { getSplNums(num % 10); } } public static void getSplNums(int num) { text = splNums.values()[num] + " " + text; } public static void getHundreds(int num) { text = hundreds.values()[num - 1] + " " + text; } public static void getTens(int num) { text = tens.values()[num - 1] + " " + text; } public static void getOnes(int num) { text = ones.values()[num - 1] + " " + text; } } Now try it. ;) [/QUOTE]
Insert quotes…
Verification
Winadiyakata thappara keeyak tibeda?
Post reply
Top
Bottom