37. Increment a Counter

 The class DeviceCounter is already defined with a private variable count, a constructor, and a getter.

Your task is to define the prefix ++ operator so that calling ++counter increments the count.

In main(): we are doing the following:

  • Read an integer n.
  • Create a DeviceCounter object with an initial value of 0.
  • Apply the ++ operator n times.
     

Printing the final count in the format:

 Final count=<value>

 

Example
 Input:

3

Output:

Final count=3

 

Input:

5

Output:

Final count=5
Loading...

Input

3

Expected Output

Final count=3