Post date: Mar 06, 2017 4:51:43 AM
Flow of Control
3.3 Loops (while / do-while)
Recommended Self-Test Exercises:
p 169-170: Ex. 22-27.
Lab Exercises:
Write a Java program which reads 5 numbers from the user using a loop and computes and displays their average
Write a Java program which computes the sum of all the odd numbers and the sum of all even numbers between 0 and 100
Ask the user to enter a integer number N. Display N factorial.
Write a program that reads 3 grades between 0 and 100. Validate the input to make sure that the user enters valid grades. Calculate the average and display the letter grade (A, B, C, D or F).
Write a Java program which reads unknown number of integers using a scanner and counts the number of odd numbers and the number of even numbers. Assume the input integers are all positive. Use a negative number as a sentinel to stop reading numbers.
Programming Challenges:
Write Java program to check if a number is palindrome in Java. A palindrome can be read in both ways: 121 is palindrome, 321 is not.
Print following structure in Java using loops:
# # # # #
# #
# #
# # # # #