Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package myApp;
- import java.util.Scanner;
- public class class03_ex04 {
- public static void main(String[] args) {
- //init vars
- int n = 0;
- //usage msg
- System.out.println("Integer: ");
- //open in_Stream, parse & close
- Scanner s = new Scanner(System.in);
- n = s.nextInt();
- s.close();
- /* Method 1 */
- //loop Until i regresses to 0, and include 0
- for (int i=n; i>=0; i-=1) {
- if (i%3 == 0) { System.out.println(i); } //check if i/3 = Integer, and print n if yes
- }
- /* Method 2
- //overwriting n, therefore destroying data that was input by user - bad practice??
- for (int i=0; i<=n; n-=1) {
- if (n%3 == 0) { System.out.println(n); } //check if i/3 = Integer, and print n if yes
- }*/
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment