Along with this lab statement is a 'solution' to the Roman numeral calculator. Create a project and import this code file into that project. Identify and fix all logic errors to make the code function properly. You may use a debugger and / or add print statements. You are not allowed to modify the structure of the code, although you may add a single line. Otherwise, you may modify expressions in the code.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

import java.util.Scanner;
public class RomanNumeralCalculator
{
    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in);
        int num;
        do
        {
            System.out.println("Please enter an integer from 1 to 5999. Enter a 
negative number to exit.");
            System.out.print("-> ");
            num = input.nextInt();
            if (num <= 0) System.exit(0);
            if (num < 6000)
            {
                String roman = "";
                while (num >= 1000)
                {
                    roman += "M";
                    num -= 1000;
                }
                switch (num % 10)
                {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                        break;
                    case 4:
                        roman += "CD";
                        num -= 400;
                        break;
                    case 5:
                    case 6:
                    case 7:
                    case 8:
                        roman += "D";
                        num -= 500;
                        break;
                    case 9:
                        roman += "CM";
                        num -= 900;
                        break;
                    default:
                        System.err.println("There is a problem with the tens 
place.");
                }
                while (num >= 100)
                {
                    roman += "C";
                    num -= 100;
                }
                
                switch (num / 10 % 10)
                {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                        break;
                    case 4:
                        roman += "XL";
                        num -= 40;
                        break;
                    case 5:
                    case 6:
                    case 7:
                    case 8:
                        roman += "L";
                        num -= 50;
                        break;
                    case 9:
                        roman += "CX";
                        num -= 90;
                        break;
                    default:
                        System.err.println("There is a problem with the tens 
place.");
                }
                while (num >= 10)
                {
                    roman += "X";
                    num -= 10;
                }
                switch (num)
                {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                        break;
     case 4:
                        roman += "IV";
                        num -= 4;
                        break;
                    case 5:
                    case 6:
                    case 7:
                    case 8:
                        roman += "v";
                        num -= 5;
                        break;
                    case 9:
                        roman += "IX";
                        num -= 9;
                        break;
                    default:       System.err.println("There is a problem with the units 
place.");
                }
                while (num > 0)
                {
                    roman += "I";
                    num--;
                }
                System.out.println(roman);
            }
        }
        while (num > 5999);
    }
}

In java can you put a lot of comments so I can understand how to do it myself 

**CS101: Lab #13  
Writing Classes IV**

Along with this lab statement is a 'solution' to the Roman numeral calculator. Create a project and import this code file into that project. Identify and fix all logic errors to make the code function properly.

You may use a debugger and/or add print statements. You are not allowed to modify the structure of the code, although you may add a single line. Otherwise, you may modify expressions in the code.
Transcribed Image Text:**CS101: Lab #13 Writing Classes IV** Along with this lab statement is a 'solution' to the Roman numeral calculator. Create a project and import this code file into that project. Identify and fix all logic errors to make the code function properly. You may use a debugger and/or add print statements. You are not allowed to modify the structure of the code, although you may add a single line. Otherwise, you may modify expressions in the code.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY