Exercises about the while looping


Using the while loop, create the following programs in Java:

1. Java program that displays the odd numbers
Write a Java application shows all the odd numbers from 1 to 100.

2. Java program that displays the even numbers
Write a Java application shows all the even numbers from 1 to 100.

3. Java program that displays the even and odd numbers
Write a Java application that receives and displays the whole even and odd numbers (separated), from 1 to that integer.

4. Java program that calculates the average grade in a classroom
Write a program that asks the user how many students have in his classroom.
Then, using a while loop, which asks the user to enter the grades of all students in the room, one at a time.
Finally, the program shows the average arithmetic classroom.

5. Finding the largest, lowest number and the average
Finding the highest, lowest and average numbers or organize sequences are the most important algorithms and studied in Computing. Java could not be different.
In our course, obviously, will not be different.

Write a Java program that prompts the user to 10 numbers, using a while loop, and the end
show which of these numbers is largest, smallest and the average.

6. Finding the two highest numbers
Write a Java program that prompts the user to 10 numbers, using a while loop, and the end
show the two largest numbers entered by the user.

7. Square asterisks
Write a program that reads the size of the side of a square and prints the square with asterisks. Its program must draw a square with sides of any size between 1 and 20.
For side equal to 5:
*****
*****
*****
*****
*****

8. Square of asterisks and blanks

Write a program that reads the size of the side of a square and prints the square with asterisks and blanks. Its program must function to square with sides of any size between 1 and 20.
For side equal to 5:
*****
*      *
*      *
*      *
*****

No comments: