Question

Ask the user to enter a year.
Using a switch statement, convert the year into Roman numerals.
Display the year as an integer, and as a Roman numeral, with a message, on the screen.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.Scanner;

public class RomanNumerals {

public static void main(String[] args){
// initialize the scanner
Scanner inputScanner = new Scanner(System.in);

// prompt the user to input a year in arabic format
System.out.print("Please enter a year: ");

// get user input
String userInput = inputScanner.next();

// convert the user input to an integer
int userYear = Integer.parseInt(userInput);

// getting the thousands and removing them from the remaining
int thousands = userYear / 1000;
int remainingYears = userYear % 1000;

// getting the hundreds and removing them from the remaining
int hundreds = remainingYears / 100;
remainingYears = remainingYears % 100;...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Arrays in Programming Language Java
Homework Solution
$20.00
Java
Programming
Computer Science
Arrays
Integers
Random Numbers
Methods
Functions
Even Elements
Odd Elements
Prime Numbers
Minimum Values
Maximum Values
Average Values
Loops
Conditions
Statements
Java Program With Strings & Integers
Homework Solution
$20.00
Java
Programming
Coding
Strings
Integers
Computer Science
Symbols
Special Characters
Reading
Writing
Rows
Columns
Statements
Conditions
Loops
Java Programming: User Defined Company
Homework Solution
$40.00
Java
Programming
Computer Science
Company
Stock Symbol
Stock Value
Constructor
Methods
Strings
Variables
Business
Finance
Economy
Hardware
Software
Arrays
Lists
ArrayList Fraction Objects in Java
Homework Solution
$15.00
Java
Programming
Computer Science
Coding
Arrays
Fractions
Numerator
Denominator
Decimal Values
Sorted List
Algorithms
Loops
Variables
Statements
Conditions
Java Programming Assignment
Homework Solution
$30.00
Java Programming
Fibonacci NumbersIntegers
Computer Science
Pseudocode
Program
Code
Get help from a qualified tutor
Live Chats