S
S
Sergey Sergey2021-04-12 09:16:31
Java
Sergey Sergey, 2021-04-12 09:16:31

Do you need to write a calendar more precisely months and days through a for loop or something else?

double JANUARY;
        System.out.println("\t\t\tЯнварь");
        System.out.println("");
            for (int i = 1; i < 8; i++) {
            System.out.print(i + "\t");
        }    
        System.out.println();
        for (int i = 8; i < 15; i++) {
            System.out.print(i +  "\t");
        }
        System.out.println();
        for (int i = 15; i < 22; i++) {
            System.out.print(i + "\t");
        }
        System.out.println();
       for (int i = 22; i < 29; i++) {
           System.out.print(i + "\t");
       } 
       System.out.println();
       for (int i = 29; i < 32; i++) {
           System.out.print(i + "\t");           
       }
}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-04-12
@vabka

You can also use for, only you have almost the same cycle repeated 5 times.
Try to somehow generalize the code so that the indents are automatically selected depending on the first day of the week.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question