-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRomanNumerals.java
63 lines (55 loc) · 1.38 KB
/
RomanNumerals.java
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//RomanNumerals.java
import java.util.Scanner;
/**
This program converts the numbers from 1 to 10 into
Roman Numerals
*/
public class RomanNumerals
{
public static void main(String[] args)
{
String input;
// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
// Get a number from the user.
System.out.print("Enter a number between 1 and 10: ");
input = keyboard.nextLine();
// Convert the number to a Roman Numeral.
switch (input)
{
case "1":
System.out.println("I");
break;
case "2":
System.out.println("II");
break;
case "3":
System.out.println("III");
break;
case "4":
System.out.println("IV");
break;
case "5":
System.out.println("V");
break;
case "6":
System.out.println("VI");
break;
case "7":
System.out.println("VII");
break;
case "8":
System.out.println("VIII");
break;
case "9":
System.out.println("IX");
break;
case "10":
System.out.println("X");
break;
default:
System.out.println("Please enter a number between 1 and 10:\n"
+ "not less than 1 and not to exceed 10");
}
}
}