Hey there! This problem might be a bit unpredictable, but give it a go and let us know how you do!
Write a lambda expression that takes an integer n as input and returns true if n is divisible by both 3 and 5, and false otherwise. Scan the input integer n from the console and print the result of applying the lambda expression to n.Lambda expressions
Lambda check for divisibility by 3 and 5
Report a typo
Sample Input 1:
15Sample Output 1:
trueSample Input 2:
9Sample Output 2:
falseWrite a program in Java 25
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
// TODO: Write a lambda expression that checks if n is divisible by both 3 and 5
System.out.println(/* TODO: Apply the lambda expression to n */);
}
}
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.