Question
Write a program to convert the user input based on the following specifications. The user input has the following format [variable-length number] [a space] [A|B|H|M]
Write a program to convert the user input based on the following specifications. The user input has the following format
[variable-length number] [a space] [A|B|H|M]
If the input is a number followed by the character "A," output the ASCII representation of (number - 1), (number), and (number +1).
Assume the number to be a 3-digit decimal number.
If the above assumption is not correct, output "PASS."
If the input is a number followed by the character "B," output the decimal equivalent.
Assume the number to be a 4-digit binary number.
If the above assumption is not correct, output "PASS."
If the input is a number followed by the character "H," output the binary equivalent.
Assume the number to be a 2-digit hexadecimal number.
If the above assumption is not correct, output "PASS."
If the input is a number followed by the character "M," output the multiplication of all digits as decimal numbers.
Assume the number to be an one to three (1 ~ 3) digit octal.
If the above assumption is not correct, output "PASS."
If none of the above conditions is met, output "Goodbye."
Make sure that you observe the following requirements:
1. You must have at least two (2) "fall through" switch statements in your submission. Use as many "fall through" constructs as possible to simplify your code.
2. Remove as many "magic numbers" as possible -- preferably none -- in your Java code. Your code will be examined closely and graded accordingly.
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