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.IOException;
- import java.io.PrintWriter;
- public class MainEvent {
- public static void main(String[] args) throws IOException {
- createFile("newFile.txt", 100);
- }
- public static void createFile(String filename, int num) throws FileNotFoundException {
- PrintWriter pw = new PrintWriter(new File(filename));
- for (int i = 1; i < num; i += 1) {
- if (i % 7 == 0 || (checkNum(i)) == 7) {
- pw.println("BOOM!");
- } else {
- pw.println(i);
- }
- }
- pw.close();
- }
- public static int checkNum(int i) {
- int newNum = 0;
- while (i > 0) {
- if (i % 10 == 7) {
- return i % 10;
- }
- i /= 10;
- }
- return newNum;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment