rename AnytoAny to capital letters and adding package declaration
This commit is contained in:
parent
9ac82a1a26
commit
e6766a92d6
@ -1,28 +1,29 @@
|
|||||||
|
package Java.Conversions;
|
||||||
|
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
//given a source number , source base, destination base, this code can give you the destination number.
|
//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 .
|
//sn ,sb,db ---> ()dn . this is what we have to do .
|
||||||
public class anytoany {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public class AnytoAny {
|
||||||
Scanner scn = new Scanner(System.in);
|
|
||||||
int sn = scn.nextInt();
|
public static void main(String[] args) {
|
||||||
int sb = scn.nextInt();
|
Scanner scn = new Scanner(System.in);
|
||||||
int db = scn.nextInt();
|
int sn = scn.nextInt();
|
||||||
int m=1,dec=0,dn=0;
|
int sb = scn.nextInt();
|
||||||
while(sn!=0)
|
int db = scn.nextInt();
|
||||||
{
|
int m = 1, dec = 0, dn = 0;
|
||||||
dec=dec+ (sn%10)*m;
|
while (sn != 0) {
|
||||||
m*=sb;
|
dec = dec + (sn % 10) * m;
|
||||||
sn/=10;
|
m *= sb;
|
||||||
}
|
sn /= 10;
|
||||||
m=1;
|
}
|
||||||
while(dec!=0)
|
m = 1;
|
||||||
{
|
while (dec != 0) {
|
||||||
dn=dn+ (dec%db)*m;
|
dn = dn + (dec % db) * m;
|
||||||
m*=10;
|
m *= 10;
|
||||||
dec/=db;
|
dec /= db;
|
||||||
}
|
}
|
||||||
System.out.println(dn);
|
System.out.println(dn);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user