FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
DataStructure-Java/String/intToRoman.java at master · joharbatta/DataStructure-Java · GitHub
joharbatta
/
DataStructure-Java
Public
Notifications
You must be signed in to change notification settings
Fork
15
Star
9
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
DataStructure-Java
/
String
/
intToRoman.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
26 lines (21 loc) · 807 Bytes
Breadcrumbs
DataStructure-Java
/
String
/
intToRoman.java
Copy path
File metadata and controls
26 lines (21 loc) · 807 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
import
java
.
util
.*;
public
class
intToRoman
{
public
static
void
main
(
String
args
[]) {
Scanner
s
=
new
Scanner
(
System
.
in
);
int
n
=
s
.
nextInt
();
romanNumeral
(
n
);
}
static
void
romanNumeral
(
int
num
) {
String
thousands
[] = {
""
,
"M"
,
"MM"
,
"MMM"
};
String
hundreds
[] = {
""
,
"C"
,
"CC"
,
"CCC"
,
"CD"
,
"D"
,
"DC"
,
"DCC"
,
"DCCC"
,
"CM"
};
String
tens
[] = {
""
,
"X"
,
"XX"
,
"XXX"
,
"XL"
,
"L"
,
"LX"
,
"LXX"
,
"LXXX"
,
"XC"
};
String
ones
[] = {
""
,
"I"
,
"II"
,
"III"
,
"IV"
,
"V"
,
"VI"
,
"VII"
,
"VIII"
,
"IX"
};
System
.
out
.
print
(
thousands
[
num
/
1000
]);
System
.
out
.
print
(
hundreds
[(
num
%
1000
)/
100
]);
System
.
out
.
print
(
tens
[(
num
%
100
)/
10
]);
System
.
out
.
print
(
ones
[
num
%
10
]);
}
}
Back
|
FazBrowse Home
|
New Git URL