I just started using Java, I completed my homework assignment in VB, but now I want to do it in java. Problem: What is the largest value of n for which 2to the nth power has fewer than 100 decimal digits. Also, fewer than 1000 decimal digits? I don't know how to tell the length of a string, or a double, or what ever type I should be using for this problem? I also don't know how to raise a number to a power? I guess just using a loop and multplying it again and again? It seems there should be a better way, but I can't find it. The more help the better, any code examples are greatly appriciated. I seem to learn best from them.
The java tutorial can be found here: http://java.sun.com/docs/books/tutorial/ The java 1.4.2 API tells you about all the various classes and the information (class members) and services (methods) they offer. To get the length of a String the String class (java.lang.String) seems a logical place to look. Check out the methods (see "method summary") of the String class and see what you find. To get an exponent you should look at the Math (java.lang.Math) class methods.