A question was posed to me today along these lines:
Write a program (with Java, /C++/C#/�) to implement a �virtual counter� that counts from 0 to 15 and then wraps to 0. The virtual counter will have 4 outputs which take values either 0 or 1. Your program should be able to display the values of the outputs in the following pattern: [image]
I have set the counter already..
..but have problems with the 4 outputs part of the question. Anyhelp?
"Wrapping around to zero" means that it would keep counting, but the value would start over at zero -- not that it would print a zero and stop after counting to 15. I should also point out that the idiomatic Java loop would have "i < 16" as its upper bound, not "i <= 15".
Now, as far as the rest of the problem goes: there are a number of ways you might do it, with varying levels of difficulty. What have you learned so far in class? (Because of course, this is a homework assignment, right?) Have you studied classes, objects, and member variables? Binary number systems and/or two's complement notation? Bitwise operators? We'll want to use things you've already learned.
A note to other Ranchers: Anyone just giving out a solution will find their post quickly deleted.