hpilo

my_7_Boom

Dec 17th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. package Main;
  2.  
  3. import java.io.File;
  4. import java.io.FileNotFoundException;
  5. import java.io.PrintWriter;
  6.  
  7. public class Tester {
  8.     public static void main(String[] args) throws FileNotFoundException {
  9.  
  10.         make7Boom("BoomTxt",1000);
  11.  
  12.     }
  13.     public static void make7Boom(String fileName,int maxNumber) throws FileNotFoundException {
  14.  
  15.         File f=new File(fileName);
  16.         PrintWriter pw=new PrintWriter(f);
  17.  
  18.         for(int count=1;count<maxNumber;count++){
  19.             if(count%7==0 || has7(count))
  20.                 pw.println("Boom");
  21.             else
  22.                 pw.println(count);
  23.         }
  24.         pw.close();
  25.     }
  26.  
  27.     public static Boolean has7(int number){
  28.  
  29.         while(number>0){
  30.             if (number%10==7)
  31.                 return true;
  32.             number/=10;
  33.         }
  34.         return false;
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment