190k views
3 votes
Question 04 (Python)

Use a while loop to find the largest integer n such that n³ is less than 12,000.

1 Answer

0 votes

Answer:

Step-by-step explanation:

You need to set the nCubed value each time in the loop:

public static void main(String[] args) {

int n = 0;

int nCubed = (int) (Math.pow(n, 3));

while (nCubed < 12000) {

n++;

nCubed = (int) (Math.pow(n, 3));

}

System.out.println("The highest integer below 12000 is " +(n-1));

}

User Ikhtesam Afrin
by
4.7k points