Exponential Cookie Clicker

Write a console program that let's the user "click" a cookie by pressing enter.

The number of clicks is a power of two that increases exponentially.

Example program output (with omissions, user input in green):

Welcome to the exponential cookie clicker. Press "x" to exit.
You have clicked the cookie 0 times.
Press Enter to click the cookie 2^0 times.

You have clicked the cookie 1 time.
Press Enter to click the cookie 2^1 times.

You have clicked the cookie 3 times.
Press Enter to click the cookie 2^2 times.

You have clicked the cookie 7 times.
Press Enter to click the cookie 2^3 times.

You have clicked the cookie 15 times.
Press Enter to click the cookie 2^4 times.

...

You have clicked the cookie 127 times.
Press Enter to click the cookie 2^7 times.

You have clicked the cookie 255 times.
Press Enter to click the cookie 2^8 times.

...

You have clicked the cookie 8191 times.
Press Enter to click the cookie 2^13 times.

You have clicked the cookie 16383 times.
Press Enter to click the cookie 2^14 times.

...

You have clicked the cookie 2147483647 times.
Press Enter to click the cookie 2^31 times.

You have clicked the cookie 4294967295 times.
You're past int's max value of 2147483647
Press Enter to click the cookie 2^32 times.

You have clicked the cookie 8589934591 times.
You're past int's max value of 2147483647
Press Enter to click the cookie 2^33 times.

...

You have clicked the cookie 9223372036854775807 times.
You're past int's max value of 2147483647
Press Enter to click the cookie 2^63 times.

You have clicked the cookie 18446744073709551615 times.
You're past long's max value of 9223372036854775807
Press Enter to click the cookie 2^64 times.

You have clicked the cookie 36893488147419103231 times.
You're past long's max value of 9223372036854775807
Press Enter to click the cookie 2^65 times.
x
Thanks for playing!
You can see that the program notes when the user has clicked the cookie more times than the maximum value of an int or long can hold:

Hints 💡

Hand in instructions

  1. Make sure your program runs correctly.
  2. Hand in your program by uploading Main.java to Moodle.