Advertisement
plamen27

9RefactorSpecialNumbers Java Fixed

Sep 27th, 2016
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. package ProgFundamentals;
  2. import java.util.Scanner;
  3.  
  4. public class OneLabNineRefactorSpecialNumbers {
  5. public static void main(String[] args){
  6. Scanner console = new Scanner(System.in);
  7. int number = console.nextInt();
  8.  
  9. for (int index = 1; index <= number; index++){
  10. int sum = 0;
  11. int actualNumber = index;
  12. String tF = "";
  13. while (index > 0){
  14. sum += index % 10;
  15. index = index / 10;
  16. }
  17. boolean trueFalse = (sum == 5) || (sum == 7) || (sum == 11);
  18. if (trueFalse){tF = "True";}
  19. else {tF = "False";}
  20. System.out.printf("%d -> " + tF + "%n", actualNumber);
  21. index = actualNumber;
  22. }
  23.  
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement