Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. public class Question5 {
  2.  
  3. public static void main(String[] args) {
  4. // 1과 10000사이의 3의 배수와 5의 배수를 출력하는데 한 줄에 10개씩 출력하고 마지막에는 3의 배수와 5의 배수의 개수와 합을 출력하는 프로그램
  5. /*
  6. * 입력 : 없음
  7. * 출력1 : 3의 배수 (10개씩)
  8. * 출력2 : 5의 배수 (10개씩)
  9. * 출력3 : 3의 배수 개수와 5의 배수의 개수 & 합
  10. */
  11. int MAX = 10000;
  12. for(int i = 1; i <= MAX; i++) {
  13. i = i + 2;
  14. System.out.print(i + " ");
  15. if(i % 30 == 0) {
  16. System.out.println();
  17. }
  18. }
  19. System.out.println();
  20. for(int j = 1; j <= MAX; j++) {
  21. j = j + 4;
  22. System.out.print(j + " ");
  23. if(j % 50 == 0) {
  24. System.out.println();
  25. }
  26. }
  27. int k;
  28. k = 10000 / 3;
  29. System.out.println("Multiple Numbers [3] : " + k);
  30. int l;
  31. l = 10000 / 5;
  32. System.out.println("Multiple Numbers [5] : " + l);
  33. System.out.println("Total Multiple Numbers [3 & 5] : " + (k + l));
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement