[SOLVED] BBM104-Quiz 5 Data Structure

30.99 $

Programming resource
Digital learning resource
Category:
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

Rate this product

Problem1: Display octal equivalents of decimal numbers

Write a main program that takes decimal numbers(between 1000-200000) from an input file (decimal.txt) as an argument and put them into any data structure, then finds and displays their octal equivalents by using a stack (octal.txt), i.e convert the number with base value 10 to base value 8.

Create a Stack class with:

  • One constructor
  • Push
  • Pop
  • Top
  • isFull()
  • isEmpty()
  • Size

You must use ONLY stack(s) for decimal-to-octal operation, don’t use other data structures such as normal array, string etc.

Algorithm:

  • Store the remainder when the number is divided by 8 into a stack.
  • Divide the number by 8 now
  • Repeat the above two steps until the number is not equal to 0.
  • Print the content now.

Figure 1: Representation of decimal-to-octal

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.