What is the output after executing method stackPro? Assume all imports for are c
ID: 3843863 • Letter: W
Question
What is the output after executing method stackPro? Assume all imports for are correct; public static vold stackPro Stack = new Stack s. push (1) for (int 1 = 2 1 leftarrow 5 [ ] int val = s.peak () s. push (1) s. push (val 2) System. out. Print (s. pop() + ), } System.out.print ln (), } Recursive method; what is printed if we call F1 (2, 4); public static void f1 (int x, int y) { if (x = y) { System.out.print("*"); } else if (x > = y) { System.out.print("=" + y + "="); } else { System.out.print(y + " "); f1 (x + 1, y - 1); System.out.print(" " + x); } }Explanation / Answer
5) Answer : Question is not clear make it more visible
6) Answer : I have solved the code given answer i am attaching in the output
public class Test {
public static void f1(int x, int y) {
if (x == y) {
System.out.println("*");
} else if (x >= y) {
System.out.println("=" + y + "=");
} else {
System.out.println(y + "");
f1(x + 1, y + 1);
System.out.println("" + x);
}
}
public static void main(String a[]) {
f1(2, 4);
}
}
output:
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.