Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please use a simplistic java program to do this because I will lose a lot of points if I use something out of hand. Thank
Please use a simplistic java program to do this because I will lose a lot of points if I use something out of hand. Thank you so much !!
For this program, you are going to write a modified version of a program you have already written this semester. Program #7 had you convert decimal numbers like 123 to their octal equivalents, which is 173 for 123. This program will work in reverse, converting octal numbers entered by the user to their equivalent decimal numbers. Your program will have one method in addition to main() that takes an integer number (that will be a proper octal number, containing only the digits 0 through 7) up to 8 digits in length and returns the equivalent integer number in decimal. Your program should prompt the user to enter a number of no greater than 8 digits. If they enter a number greater than 8 digits or a value less than 0, it should re-prompt the user to enter a number again. You do not need to check if the digits are valid octal numbers (0-7), as this is guaranteed. In addition to your main method, your class will have a method called convert implemented like this: public static int convert int octalNumber The majority of your main method should look like the following code. You will need to make some changes to do 8-digit data validation before calling the convert method. public static void main String args [J int foo; Scanner sc new Scanner System. in System.out print ("Enter up to an 8-digit octal number and I'll convert it foo sc .next Int System out printf "Sd: Sd ", foo convert (foo) The output of the program is illustrated in the code above. You must print the original octal number, followed immediately by a colon, followed immediately by the decimal equivalent of the conversionStep 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