Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Main;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.PrintWriter;
- public class Tester {
- public static void main(String[] args) throws FileNotFoundException {
- make7Boom("BoomTxt",1000);
- }
- public static void make7Boom(String fileName,int maxNumber) throws FileNotFoundException {
- File f=new File(fileName);
- PrintWriter pw=new PrintWriter(f);
- for(int count=1;count<maxNumber;count++){
- if(count%7==0 || has7(count))
- pw.println("Boom");
- else
- pw.println(count);
- }
- pw.close();
- }
- public static Boolean has7(int number){
- while(number>0){
- if (number%10==7)
- return true;
- number/=10;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment