Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package testowyprogram;
- import java.io.FileNotFoundException;
- import java.io.PrintWriter;
- public class TestowyProgram {
- public static void main(String[] args) throws FileNotFoundException {
- boolean weszlo = true;
- int one = 0;
- int last = 0;
- PrintWriter zapis = new PrintWriter("c:\\TEST\\test.txt");
- for (int i = 1000; i <= 9999; i++) {
- String test = Integer.toString(i);
- char pierw = test.charAt(0);
- int pierwInt = Character.getNumericValue(pierw);
- char drug = test.charAt(1);
- int drugInt = Character.getNumericValue(drug);
- char trzy = test.charAt(2);
- int trzyInt = Character.getNumericValue(trzy);
- char cztery = test.charAt(3);
- int czteryInt = Character.getNumericValue(cztery);
- if (pierwInt != 0 && drugInt != 0 && trzyInt != 0 && czteryInt != 0) {
- if (i % pierwInt == 0 && i % drugInt == 0 && i % trzyInt == 0 && i % czteryInt == 0) {
- if(weszlo == true){
- one = i;
- }
- weszlo = false;
- System.out.println(i);
- zapis.write(i+";");
- last = i;
- }
- }
- } // popek żondzi
- zapis.close();
- System.out.println("Program znalazl liczby od "+one+"do"+last);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement