Write a console program that lets the user "click" a cookie by pressing enter.
The counted clicks increase exponentially after each time the user presses enter.
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:
int is 231-1. About 2 billion.long is 263-1. About 9 quintillion (9 * 1018)BigDecimal to represent your numbers. Find out how to perform exponentiation with BigDecimal.BigDecimal's method valueOf to convert from a long to a BigDecimal.BigDecimal is larger than another one, use its compareTo method." inside a string, you need to escape the quote: System.out.println("Has \"quotes\" inside")