Help us understand the problem. What is going on with this article?

3の倍数の出力

More than 1 year has passed since last update.

8/11追記 
・3/0はエラー(ArithmeticException)になるけど、0/3はエラーでない

基本ルール:3の倍数は"!!"がつく
1. 入力された数値を1から順に出力
2. 1を逆に出力
3. ランダムな数値を15個出力

Nabeatsu.java
import java.util.Random;
import java.util.Scanner;

public class Nabeatsu {

    public static void main(String[] args) {
        //3の倍数だけアホになる
        Scanner scan = new Scanner(System.in);
        int number = scan.nextInt();
        for(int i = 1;i <= number; i++) {
            if(i % 3 == 0) 
                System.out.println(i + "!!");   
            else
                System.out.println(i);
        }
        for(int i = number;i > 0; i--) {  //逆順に
            if(i % 3 == 0) 
                System.out.println(i + "!!");   
            else
                System.out.println(i);
        }

        Random random = new Random();
        int i = 0;
        while(i<15) {
            int ran = random.nextInt(500);
            if(ran % 3 == 0) {
                System.out.println(ran+ "!!");  
                i++;
            }else {
                System.out.println(ran);
                i++;

            }
        }
    }
}
sumy
Java勉強中です。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away