0

I want to change a while loop to a for loop but not sure how to do it. This is the loop.

[LIST=1]
[*]public static void main(String[] args) 
[*] { 
[*]   String input = JOptionPane.showInputDialog( 
[*]      "Please enter a number, 0 to quit:"); 
[*]   int n = Integer.parseInt(input); 
[*]   int i = 1; 
[*]   while (n * n > Math.pow(2,i)) 
[*]   { 
[*]       i++; 
[*]   }    
[*] System.out.println("2 raised to " + i 
[*]      + " is the first power of two greater than " + n + " squared"); 
[*]   } 
[*] }
[/LIST]
3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by breandan
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.