dm6801

20171109 - 03 - classEx_03

Nov 11th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. package myApp;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class class03_03 {
  6.  
  7.     public static void main(String[] args) {
  8.         //init vars
  9.         int n       = 0;
  10.        
  11.         //usage msg
  12.         System.out.println("Integer: ");
  13.        
  14.         //open in_Stream, parse & close
  15.         Scanner s = new Scanner(System.in);
  16.         n = s.nextInt();
  17.         s.close();
  18.        
  19.         //loop n+1 times  (+1 to include 0 in our check)
  20.         for (int i=0; i<=n; i++) {
  21.             if (i%3 == 0) { System.out.println(i); } //check if i/3 = Integer, and print n if yes
  22.         }
  23.  
  24.     }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment