1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Angelina_Jolie [31]
4 years ago
12

Write a program that asks the user to enter a number within the range of 1 through 10. Use a switch statement to display the Rom

an numeral version of that number. Input Validation: Do not accept a number less than 1 or greater than 10. Prompts And Output Labels. Use the following prompt for input: "Enter a number in the range of 1 - 10: ". The output of the program should be just a Roman numeral, such as VII. CLASS NAMES. Your program class should be called RomanNumerals
Computers and Technology
1 answer:
Snezhnost [94]4 years ago
6 0
<h2>Answer:</h2>

//import the Scanner class to enable user's input

import java.util.Scanner;

// Declare the class header with RomanNumerals as name

public class RomanNumerals {

   // Declare the main method where execution begins

   public static void main(String[] args) {

       //Instantiate an object of the Scanner class to allow user's to enter the number

       Scanner userinputscan = new Scanner(System.in);

       

       //Display a message to prompt the user to enter a number

       System.out.println("Enter a number in the range of 1 - 10");

       

       //Receive the number from the user and store in an int variable

       int usernumber = userinputscan.nextInt();

       

       

       //Start the switch statement using the usernumber

       switch (usernumber) {

       

           //Check if the number is 1

           //Display I

           //Then break out of the switch statement

           case 1 :  

               System.out.println("I");

               break;

               

           //If the number is 2

           //Display II

           //Then break out of the switch statement

           case 2 :

               System.out.println("II");

               break;

               

           //If the number is 3

           //Display III

           //Then break

           case 3:

               System.out.println("III");

               break;

               

           //If the number is 4

           //Display IV

           //Then break

           case 4:

               System.out.println("IV");

               break;

               

           //If the number is 5

           //Display V

           //Then break

           case 5:

               System.out.println("V");

               break;

               

           //If the number is 6

           //Display VI

           //Then break

           case 6:

               System.out.println("VI");

               break;

               

           //If the number is 7

           //Display VII

           //Then break

           case 7:

               System.out.println("VII");

               break;

             

           //If the number is 8

           //Display VIII

           //Then break

           case 8:

               System.out.println("VIII");

               break;

           

           //If the number is 9

           //Display IX

           //Then break

           case 9:

               System.out.println("IX");

               break;

               

           //If the number is 10

           //Display X

           //Then break

           case 10:

               System.out.println("X");

               break;

           

           //If the number is out of range [That is the default case]

           //Display an error message.  

           default:

               System.out.println("Error: The number is not within range");

               break;

               

       }          //End of switch statement

       

       

  }  // End of main method

   

}  // End of class declaration

<h2>Explanation:</h2>

The above code has comments explaining every part of the code. Please go through the comments.

The actual code has been written in bold face to distinguish it from comments.

===============================================================

<h2>Sample Output 1:</h2>

>> Enter a number in the range of 1 - 10

45

>> Error: The number is not within range

================================================================

<h2>Sample Output 2:</h2>

>> Enter a number in the range of 1 - 10

8

>> VIII

<h2 /><h2 /><h2 />
You might be interested in
N the following pseudocode, what percentage raise will an employee in Department 8 receive?
goldenfox [79]

Answer:

"MEDIUM_RAISE" is the correct answer for the above question.

Explanation:

  • In the above pseudo-code, The first if statement will false because the question suggests that the department value is 8, which is greater than 5. But the first if statement states that the department value is less than 5.
  • Then the else-if statement gets checked which gives the true result. It is because the value of the department variable is 8, which is less than 14.
  • So the else-if statement block will be executed which assigns the MEDIUM_RAISE value to the raise.
  • Hence the answer is "MEDIUM_RAISE".

4 0
3 years ago
A personal career profile for can be used to match what you know about yourself to what you know about different careers
mel-nik [20]

Answer:

B

Explanation:

give answers next time pls so i can help you!!

3 0
4 years ago
Read 2 more answers
Application of optical fibre​
densk [106]

Answer:

Internet data transfer.

Explanation:

Optical fibre can be used to move information from one place to another. It is used in internet communications, cable television broadcasting, and telephone communication. One common application is for the transfer of data over the internet. Chances are your browser was able to download this web page by receiving data that came from Brainly's servers, and from my computer, through a fibre optic cable.

4 0
3 years ago
Select three nonrenewable types of energy.
trapecia [35]

Answer:

nuclear, coal,petroleum

6 0
3 years ago
Which statement best describes antivirus software?
valentina_108 [34]
It identifies and removes viruses in computers
7 0
4 years ago
Other questions:
  • Business ethics are?
    9·1 answer
  • HELP PLEASE!!!!!!!!
    10·1 answer
  • Why is the answer A?
    6·1 answer
  • What is ‘Black-Box’ testing?
    14·1 answer
  • Edhesive 4.1 question 1
    9·1 answer
  • Using the world_x database you installed in Module 1, list the countries and the capitals of each country. Modify your query to
    11·1 answer
  • What are the steps to creating a blank database? Use the drop-down menus to complete them.
    9·1 answer
  • The TCP congestion control measure techniques fall into two categories: retransmission timer management and ________ management
    13·1 answer
  • Which mechanical switches are the loudest and clickiest?
    15·1 answer
  • Trish has bought a new computer that she plans to start on after a week
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!