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...


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++)


System.out.println(n);


4. What output is produced by the following code?


for (int n = 4; n > 0; n––)


System.out.println(n);






Nov 26, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here