Question: for each call below to the trick method write the output that is produces as it would appear on the console public static void trick

for each call below to the trick method write the output that is produces as it would appear on the console
public static void trick (int x, int y)
{
int s=0;
while (x >0 && 2* y >=x)
{
System.out.print(s +"");
y = y - x;
x--;
s = s + x;
}
System.out.println(s);
}
a) trick (-2,-6);
b) trick (2,3);
c) trick (4,8);
d) trick (10,31);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!