Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the synopsis of the program: Octonumero (ver 2) An octonumero of a number x is found as follows. Convert x to base 8,

This is the synopsis of the program:

Octonumero (ver 2)

An octonumero of a number x is found as follows.

  1. Convert x to base 8, call this p
  2. Sort the digits of p in increasing order, call this q
  3. Subtract q from p in octal (convert q and p to decimal, subtract and convert back to octal)
  4. Repeat steps 2 - 3, four more times or until the digits in the result are in sorted order.
  5. Convert the number back to decimal

Example:

x = 341810

convert: 341810 = 65328

sort and subtract: 65328 - 23568 = 41548

4 more times: 41548 - 14458 = 25078

3 more times: 25078 - 2578 = 2230,

2 more times: 22308 - 2238 = 20058

last time: 20058 - 258 = 17608

convert: 17608 = 100810

How do I do these methods:

  1. public static int arrayToNum ( int[] arr )

arrayToNumreturns the elements as one number such that each element becomes a digit of the returned value. The element atarr.length - 1is the ones digits

  1. public static int octalSubtract (int larger, int smaller)

octalSubtractwill return the difference between larger and smaller in base 8

Can you please send me the code, as I learn better like that than the sentence explanations please? Thanks again for your time :D

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Algorithms

Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest

3rd edition

978-0262033848

More Books

Students also viewed these Programming questions

Question

Explain the concept of shear force and bending moment in beams.

Answered: 1 week ago