From e6766a92d6cd1c8f5e82e0a3fea2644b09e1eacb Mon Sep 17 00:00:00 2001 From: khalil2535 Date: Sun, 1 Apr 2018 22:09:06 +0300 Subject: [PATCH] rename AnytoAny to capital letters and adding package declaration --- Conversions/AnytoAny.java | 45 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/Conversions/AnytoAny.java b/Conversions/AnytoAny.java index a1acdb1a..a86e2d04 100644 --- a/Conversions/AnytoAny.java +++ b/Conversions/AnytoAny.java @@ -1,28 +1,29 @@ +package Java.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); - } +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); + } }