ChaseKeskinyan

Untitled

Dec 19th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3. /**
  4. Chase Keskinyan
  5. 12/16/19
  6. Mr.Goldman
  7. Period 9 APCSA
  8. */
  9. public class RomanNumeral
  10. {
  11. static PrintStream richard;
  12. public static int getDigitValue(char ch)
  13. {
  14. if(ch == 'I')
  15. {
  16. return 1;
  17. }
  18.  
  19. else if(ch == 'V')
  20. {
  21. return 5;
  22. }
  23.  
  24. else if(ch == 'X')
  25. {
  26. return 10;
  27. }
  28.  
  29. else if(ch == 'L')
  30. {
  31. return 50;
  32. }
  33.  
  34. else if(ch == 'C')
  35. {
  36. return 100;
  37. }
  38.  
  39. else if(ch == 'D')
  40. {
  41. return 500;
  42. }
  43.  
  44. else if(ch == 'M')
  45. {
  46. return 1000;
  47. }
  48.  
  49. else
  50. {
  51. return 0;
  52. }
  53. }
  54.  
  55. public static void main(String[] args)throws Exception
  56. {
  57. try
  58. {
  59. Scanner chase = new Scanner(new FileInputStream("RomanNumeralFile.txt"));
  60. while(chase.hasNext())
  61. {
  62. String tmp = chase.nextLine();
  63. if(tmp.length()== 1)
  64. {
  65. System.out.println(tmp.charAt(0).getDigitValue());
  66. }
  67. else
  68. {
  69. for(int j = 1; j < tmp.length(); j++)
  70. {
  71. if(tmp.charAt(j).getDigitValue < tmp.charAt(j+1).getDigitValue)
  72. {
  73.  
  74. }
  75. }
  76. }
  77. }
  78. }
  79.  
  80. catch(IOException e)
  81. {
  82. System.out.println("Invalid File Name");
  83. }
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment