FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/Conversions/AnytoAny.java at master · java66liu/Java · GitHub
java66liu
/
Java
Public
forked from
TheAlgorithms/Java
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java
/
Conversions
/
AnytoAny.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (26 loc) · 774 Bytes
Breadcrumbs
Java
/
Conversions
/
AnytoAny.java
Copy path
File metadata and controls
30 lines (26 loc) · 774 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
30
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
);
scn
.
close
();
}
}
Back
|
FazBrowse Home
|
New Git URL