Output:
Click Here For Java Online Compiler
Solution:
Input the first integer number: 1 Input the second integer number: 9 The result is: true ----------------------------------- Input the first integer number: 15 Input the second integer number: 5 The result is: true ----------------------------------- Input the first integer number: 123 Input the second integer number: 10 The result is: true
Click Here For Java Online Compiler
Solution:
import java.util.Scanner; public class AddOrDiffEquals10 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Input the first integer number: "); int x = scanner.nextInt(); System.out.print("Input the second integer number: "); int y = scanner.nextInt(); System.out.print("The result is: " + calculate(x, y)); System.out.print("\n"); } public static boolean calculate(int p, int q) { if (p == 10 || q == 10) { return true; } return ((p + q) == 10 || Math.abs(p - q) == 10); } }
comment 0 comments:
more_vertsentiment_satisfied Emoticon