1. Imagine a program that reads the population of a city using the following
statements:
System.out.print("Enter the population of the city: ");
int population = keyboard.nextInt( );
Write a while loop after these statements that ensures that population is
positive. I f the user enters a population that is either negative or zero, ask
the user to enter a nonnegative value.
2. What output is produced by the following code?
for (int n = 1; n <=>
System.out.println(n);
3. What output is produced by the following code?
int n;
for (n = 1; n > 4; n++)
4. What output is produced by the following code?
for (int n = 4; n > 0; n––)
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here