Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package DataTypesVars2205;
- import java.util.Scanner;
- public class Problem10specialNum {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = scanner.nextInt();
- for (int i = 1; i<=n; i++) {
- String numToString = Integer.toString(i);
- int sumInt = 0;
- for (int x = 0; x<=numToString.length()-1; x++) {
- int currentInt = Character.getNumericValue(numToString.charAt(x));
- sumInt+=currentInt;
- }
- if (sumInt==5 || sumInt==7 || sumInt == 11) {
- System.out.printf("%d -> True%n", i);
- } else {
- System.out.printf("%d -> False%n", i);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement