Help coderanch get a
new server
by contributing to the fundraiser

Dania Khan

Greenhorn
+ Follow
since Oct 07, 2014
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Dania Khan

After multiple tries and erasures, this is what I got:

9 years ago
Hi All,

I'm trying to teach myself Java and came across a problem I'm hoping to get insight on. I need to basically figure out what the possible output is for candidate blocks of code, which would be substituted in the program where the underline is. Here it is:



Candidates:
x = x + 3;
x = x + 6;
x = x + 2;
x ++;
x --;
x = x + 0;

Possible output:
45 6
36 6
54 6
60 10
18 6
6 14
12 14

I've tried iterating through this code, but my results will either match only with some of the x values of the possible output, or not at all...I'm not sure what I'm doing wrong. I would appreciate any assistance. Thanks!
9 years ago