Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Help with this java problem ?

Write a program which performs the circular permutation of four variables A , B, C, and D. Two versions of the program can be created: one that performs the circular permutation to the right, and the other that performs circular permutation to the left

1 Answer

Thanks ! I was trying to find a way around loops but was just missing a couple of things ;)

I was working with integers rather than characters but I was wondering why did you use Scanner ?

Rares Conea
Rares Conea
Courses Plus Student 15,000 Points

First i wanted to say A = 'A', B = 'B' and so on, but when i printed the variables of screen in this format I thought it will be hard to read. You can work the same with integers, just change the type and assigment of A, B, C, D and aux; I used scanner because i wanted to manually give the number of times i want to permute. I give the number from keyboard, store it in number variable and use the variable in the for loop.

AH alright I actually gave each variable an integer A=1 B=2... and tried to mathematically permute them by add 3 to A, 1 to B, -1 to C and 1 to D but didnt work

Rares Conea
Rares Conea
Courses Plus Student 15,000 Points

It did not work because that is not what "permute" means.