You are on page 1of 2

Practice

Course:
Programming Using Java
Topic: Loops. Part 1
Task 1
The user enters two numbers from the keyboard. Display
all numbers in the specified range.
Task 2
The user enters two numbers from the keyboard. Display
all even numbers in the specified range.
Task 3
The user enters two numbers from the keyboard. Display
all odd numbers in the specified range. If the range limits were
specified incorrectly, normalize them. For example, the user
entered 20 and 11, normalize the limits so that 11 becomes
the beginning of the range and 20 the end.
Task 4
The user enters two numbers from the keyboard. Calculate
the sum and arithmetic mean of the numbers in the specified
range.
Task 4
The user enters a number from the keyboard. Calculate
the factorial of the number. For example, if 3 was entered,
the factorial would be 1*2*3 = 6.
The factorial formula is n! = 1*2*3…*n, where n is the num-
ber to calculate the factorial.
1
Practice

Task 5
The user enters the length of a line. Display a horizontal
line made of * symbols of the specified length.
For example, if the user entered 7, the output would be
as follows:
*******
Task 6
The user enters the length of a line and a symbol which
the line should be made of. Display a vertical line made of
the entered symbol of the specified length.
For example, if the user entered 5 and %, the output would
be as follows:
%
%
%
%
%
Task 7
The user enters two numbers (the beginning and the end
of the range). Analyze all the numbers in this range. The output
should be according to the rules below.
If the number is divisible by 3 (it is divided by 3 without
a remainder), display the word Fizz. If the number is divisible
by 5, display the word Buzz. If the number is divisible by 3
and 5, output Fizz Buzz. If the number is not divisible by 3 or
5, output the number itself.

You might also like