GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Java/Conversions/AnytoAny.java at master · blake2002/Java Expand file tree/ Copy pathAnytoAny.javaMore file actions 29 lines (25 loc) · 753 Bytes / Copy pathAnytoAny.javaFile metadata and controls29 lines (25 loc) · 753 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 package Conversions; import java.util.Scanner; //given a source number , source base, destination base, this code can give you the destination number. //sn ,sb,db ---> ()dn . this is what we have to do . public class AnytoAny { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int sn = scn.nextInt(); int sb = scn.nextInt(); int db = scn.nextInt(); int m = 1, dec = 0, dn = 0; while (sn != 0) { dec = dec + (sn % 10) * m; m *= sb; sn /= 10; } m = 1; while (dec != 0) { dn = dn + (dec % db) * m; m *= 10; dec /= db; } System.out.println(dn); } } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |