Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I do really bad at stack and queue so I got stuck with my Data Structure and Alg

ID: 3535277 • Letter: I

Question

I do really bad at stack and queue so I got stuck with my Data Structure and Algorithm homework. Can someone help me?

Explanation / Answer

package stack; import java.util.Scanner; /** * * @author ACHCHUTHAN */ public class Decimal2oct extends Stack { int decimal; public Decimal2oct(int n) { super(n); System.out.println("Enter nonnegative integer :"); Scanner input = new Scanner(System.in); decimal = input.nextInt(); } /** * push the value to stack */ public void setHex2Stack() { if (decimal == 0) { push(0); } while (decimal > 0) { int digit = decimal % 8; push(digit); decimal = decimal / 8; } } /** * @return octal string value */ public String getHexa() { String h = ""; while (!isEmpty()) { h = h + pop(); } return h; } public static void main(String args[]) { Decimal2oct d = new Decimal2oct(16); d.setHex2Stack(); d.print(); System.out.println("Octal : " + d.getHexa()); decimal2hexa d2 = new decimal2hexa(16); d2.setHex2Stack(); d2.print(); System.out.println("Octal : " + d2.getHexa()); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote