Question
/** Converts Roman numerals to decimal value */ import java.util.Scanner; public class RomanNumerals { public static void main(String[] args) { Scanner in = new Scanner(I
/** Converts Roman numerals to decimal value */ import java.util.Scanner;
public class RomanNumerals { public static void main(String[] args) { Scanner in = new Scanner("I C X D M L");
char romanNumeral = in.next().charAt(0); System.out.println("Value: " + valueOf(romanNumeral) + " Expected: 1") ; romanNumeral = in.next().charAt(0); System.out.println("Value: " + valueOf(romanNumeral) + " Expected: 100") ; romanNumeral = in.next().charAt(0); System.out.println("Value: " + valueOf(romanNumeral) + " Expected: 10") ; romanNumeral = in.next().charAt(0); System.out.println("Value: " + valueOf(romanNumeral) + " Expected: 500") ; romanNumeral = in.next().charAt(0); System.out.println("Value: " + valueOf(romanNumeral) + " Expected: 1000") ; romanNumeral = in.next().charAt(0); System.out.println("Value: " + valueOf(romanNumeral) + " Expected: 50") ; } /** Gives the value of the Roman numerals I X L C D M @param numeral a single Roman numeral @return the integer value of numeral */ //-----------Start below here. To do: approximate lines of code = 14 // write a static method valueOf with the appropriate parameters and return type. // must be an M //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started