FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Crash-Course/Task/Task10.java at master · sundramsinghdev007/Java-Crash-Course · GitHub
sundramsinghdev007
/
Java-Crash-Course
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Crash-Course
/
Task
/
Task10.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (37 loc) · 713 Bytes
Breadcrumbs
Java-Crash-Course
/
Task
/
Task10.java
Copy path
File metadata and controls
37 lines (37 loc) · 713 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
31
32
33
34
35
36
37
import
java
.
util
.*;
class
BinaryToDecimal
{
int
dec
=
0
;
public
int
BtoD
(
int
n
)
{
int
i
,
v
;
int
length
=
String
.
valueOf
(
n
).
length
();
for
(
i
=
0
;
i
<
length
;
i
++)
{
if
(
n
==
0
)
{
System
.
out
.
print
(
"Enter the valid number"
);
}
else
{
v
=
n
%
10
;
dec
+=
v
*
Math
.
pow
(
2
,
i
);
n
=
n
/
10
;
}
}
return
dec
;
}
}
class
task
{
public
static
void
main
(
String
...
args
)
{
int
Bno
,
sum
;
BinaryToDecimal
d
=
new
BinaryToDecimal
();
Scanner
sc
=
new
Scanner
(
System
.
in
);
System
.
out
.
print
(
"Enter the binary number="
);
Bno
=
sc
.
nextInt
();
sum
=
d
.
BtoD
(
Bno
);
System
.
out
.
print
(
sum
);
}
}
Back
|
FazBrowse Home
|
New Git URL