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
RHCSA, RHCE, AWS, Docker, Kubernetes Training
Sanjeewani95
Updated:
Tuesday at 10:28 AM
🛡️ Kaspersky Antivirus – 1 Year / 1 Device | Rs. 2,300 | Only 9 Left
KSPathirana
Updated:
Monday at 2:42 PM
Ad icon
Professional CCTV Installation Service
Techguy231
Updated:
Sep 6, 2026
Ad icon
I'll research & write an article - Rs. 2000 onwards
Blogerwiki
Updated:
Sep 3, 2026
House Plan
lenura
Updated:
Sep 2, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
Java Problem
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="chinthakapathir" data-source="post: 9867801" data-attributes="member: 39276"><p>[CODE]import java.util.*;</p><p></p><p>/**</p><p> *</p><p> * @author Chinthy</p><p> */</p><p>public class Base</p><p>{</p><p></p><p></p><p> public static void main(String args[])</p><p> {</p><p> int number;</p><p> double val = 0;</p><p> int length;</p><p> int base;</p><p></p><p> System.out.println("Enter value: ");</p><p> Scanner scan1 = new Scanner(System.in);</p><p> number = scan1.nextInt();</p><p> length = String.valueOf(number).trim().length();</p><p></p><p> System.out.println("Enter base value: ");</p><p> Scanner scan2 = new Scanner(System.in);</p><p> base = scan2.nextInt();</p><p></p><p> while(number>0)</p><p> {</p><p> double [] rem = new double[length];</p><p> for(int i =0;i<length;i++)</p><p> {</p><p> </p><p> rem[i] = number % 10;</p><p> number = number / 10;</p><p></p><p> val = val + (rem[i]*(Math.pow(base, i)));</p><p> }</p><p></p><p> }</p><p></p><p> System.out.println("Value: "+val);</p><p></p><p></p><p></p><p></p><p></p><p> }</p><p></p><p></p><p></p><p>}</p><p>[/CODE]</p><p></p><p><span style="font-size: 12px"><span style="color: Blue">Checked two three values. Harida danne na dan haduwe... i think this should work.</span></span><img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /><img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /><img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /></p></blockquote><p></p>
[QUOTE="chinthakapathir, post: 9867801, member: 39276"] [CODE]import java.util.*; /** * * @author Chinthy */ public class Base { public static void main(String args[]) { int number; double val = 0; int length; int base; System.out.println("Enter value: "); Scanner scan1 = new Scanner(System.in); number = scan1.nextInt(); length = String.valueOf(number).trim().length(); System.out.println("Enter base value: "); Scanner scan2 = new Scanner(System.in); base = scan2.nextInt(); while(number>0) { double [] rem = new double[length]; for(int i =0;i<length;i++) { rem[i] = number % 10; number = number / 10; val = val + (rem[i]*(Math.pow(base, i))); } } System.out.println("Value: "+val); } } [/CODE] [SIZE="3"][COLOR="Blue"]Checked two three values. Harida danne na dan haduwe... i think this should work.[/COLOR][/SIZE]:D:D:D [/QUOTE]
Insert quotes…
Verification
Dawasata paya keeyak thibeda?
Post reply
Top
Bottom