Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- /**
- Chase Keskinyan
- 12/16/19
- Mr.Goldman
- Period 9 APCSA
- */
- public class RomanNumeral
- {
- static PrintStream richard;
- public static int getDigitValue(char ch)
- {
- if(ch == 'I')
- {
- return 1;
- }
- else if(ch == 'V')
- {
- return 5;
- }
- else if(ch == 'X')
- {
- return 10;
- }
- else if(ch == 'L')
- {
- return 50;
- }
- else if(ch == 'C')
- {
- return 100;
- }
- else if(ch == 'D')
- {
- return 500;
- }
- else if(ch == 'M')
- {
- return 1000;
- }
- else
- {
- return 0;
- }
- }
- public static void main(String[] args)throws Exception
- {
- try
- {
- Scanner chase = new Scanner(new FileInputStream("RomanNumeralFile.txt"));
- while(chase.hasNext())
- {
- String tmp = chase.nextLine();
- if(tmp.length()== 1)
- {
- System.out.println(tmp.charAt(0).getDigitValue());
- }
- else
- {
- for(int j = 1; j < tmp.length(); j++)
- {
- if(tmp.charAt(j).getDigitValue < tmp.charAt(j+1).getDigitValue)
- {
- }
- }
- }
- }
- }
- catch(IOException e)
- {
- System.out.println("Invalid File Name");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment