02.2 PB-Java-Conditional-Statements-Lab
02.2 PB-Java-Conditional-Statements-Lab
Problems for lab exercise for the "Programming Basics" course @ SoftUni Global.
Submit your code in the Judge system: https://judge.softuni.org/Contests/Compete/Index/3449
1. Excellent Result
Write a console program that reads a rating (integer) entered by the user and prints "Excellent!" if the score is 5 or
higher.
Inpu Inpu
Input Output Output Output Input Output
t t
6 Excellent! 4 (no output) 5 Excellent! 3 (no output)
You already have a project with one class in it. It remains to write the code to solve the task.
2. Create a main method by going to the "ExcellentResult" class (between curly brackets) and type:
3. Go to the body of the main (String [] args) method (between the curly braces). Create a Scanner object to read
from the console and read a floating-point number - the grade:
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Follow us: Page PAGE \*
MERGEFORMAT 6
4. Check the value of the assessment. If it is greater than or equal to 5, print the conditional output:
5. Start the program with [Ctrl + Shift + F10] and test it with different input values:
2. Greater Number
Write a program that reads two integers entered by the user and prints the larger of the two.
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Follow us: Page PAGE \*
MERGEFORMAT 6
2. Compare whether the first
number num1 is greater
than the second num2. Print
the larger number.
3. Even or Odd
Write a program that reads an integer entered by the user and prints whether it is even or odd.
3. Check that the number is even by dividing it by 2, and check what is the remainder of the division. Print the
output depending on the condition:
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Follow us: Page PAGE \*
MERGEFORMAT 6
Testing in the Judge System
Test the solution to this problem here: https://judge.softuni.org/Contests/Compete/Index/3449#2
4. Password Guess
Write a program that reads a password (string) entered by the user and checks if the entered password matches the
phrase "s3cr3t!P@ssw0rd". In case of coincidence, display "Welcome". In case of discrepancy, display "Wrong
password!".
5. Number 100...200
Write a program that reads an integer entered by the user and checks if it is below 100, between 100 and 200 or
above 200. If the number is:
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Follow us: Page PAGE \*
MERGEFORMAT 6
6. Speed Info
Write a program that reads the speed (floating-point number) entered by the user and prints speed information.
7. Area of Figures
Write a program in which the user enters the type and dimensions of a geometric figure and calculates its area. The
figures are of four types: square, square, rectangle, circle, and triangle. The first line of the input reads the type of
figure (string with the following options: square, rectangle, circle, or triangle).
● If the figure is a square: on the next line read a floating-point number - the length of its side
● If the figure is a rectangle: on the next two lines read two floating-point numbers - the lengths of its sides
● If the figure is a circle: on the next line read a floating-point number - the radius of the circle
● If the figure is a triangle: on the next two lines read two floating-point numbers - the length of its side and
the length of the height to it
Round the result up to 3 digits after the decimal point.
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Follow us: Page PAGE \*
MERGEFORMAT 6