60 665
Assignments Done
97,7%
Successfully Done
In April 2018

Answer to Question #2526 in Java | JSP | JSF for hari

Question #2526
Write a function called powersOfTwo that prints the first 10 powers of 2 (starting with 2). The function takes no parameters and doesn't return anything.
Expert's answer
public class Power {

public static void powersOfTwo() {
& for (int i = 2; i<11; i++) {
& System.out.println(i + " power of 2 = " + Math.round(Math.pow(2, i)));
& }
}

public static void main(String[] args) {
& powersOfTwo();
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions