• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 512
  • Last Modified:

rewrite the following java method with the modulo operator - urgent

hi, i need to rewrite the method below without the modulo operator, using an if statement instead -

public void increment()
{
value = (value + 1) % limit;
}

anyone?  thanks, spower
0
spower22
Asked:
spower22
  • 2
1 Solution
 
CEHJCommented:
You might like to roll the value, in which case, try
    public static void increment()
    {
        if (++value == limit)
            value = 0;
    }

Open in new window

0
 
CEHJCommented:
:-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now