We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ec85180 commit ea3efffCopy full SHA for ea3efff
1 file changed
src/main/java/ru/mentee/power/IfElse.java
@@ -0,0 +1,26 @@
1
+package ru.mentee.power;
2
+
3
+import java.util.Scanner;
4
5
+public class IfElse {
6
7
+ public static void main(String[] args) {
8
+ int age;
9
+ boolean hasLicense;
10
+ Scanner scanner = new Scanner(System.in);
11
+ System.out.print("Enter your age:");
12
+ age = scanner.nextInt();
13
+ System.out.println("Do you have driver's license? yes/no");
14
+ if (scanner.nextLine().equalsIgnoreCase("yes")) {
15
+ hasLicense = true;
16
+ } else {
17
+ hasLicense = false;
18
+ }
19
+ if (age >= 18 && hasLicense){
20
+ System.out.println("You can rent a car!");
21
+ }else{
22
+ System.out.println("Sorry, you can't rent a car.");
23
24
25
26
+}
0 commit comments