Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. package DataTypesVars2205;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Problem10specialNum {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8. int n = scanner.nextInt();
  9.  
  10. for (int i = 1; i<=n; i++) {
  11. String numToString = Integer.toString(i);
  12. int sumInt = 0;
  13. for (int x = 0; x<=numToString.length()-1; x++) {
  14. int currentInt = Character.getNumericValue(numToString.charAt(x));
  15. sumInt+=currentInt;
  16. }
  17. if (sumInt==5 || sumInt==7 || sumInt == 11) {
  18. System.out.printf("%d -> True%n", i);
  19. } else {
  20. System.out.printf("%d -> False%n", i);
  21. }
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement