S
S
Sergey Sergey2021-04-18 13:06:53
Java
Sergey Sergey, 2021-04-18 13:06:53

How in the code below do not write the date of January in February, but that the transition from 31 to 1 is carried out according to the day of the week?

public class Month {
    public static void main(String[] args) {
        double JANUARY;
        System.out.println("\t\t\tЯнварь");
        System.out.println("");
        System.out.println("Пн\tВт\tСр\tЧт\tПт\tСб\tВс");
            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");           
       }
       System.out.println();
        double FEBRUARY;
        System.out.println("\t\t\tФевраль");
        System.out.println("");
        System.out.println("Пн\tВт\tСр\tЧт\tПт\tСб\tВс");
        for (int i = 29; i < 32; i++) {
           System.out.print(i + "\t");           
       }
       for (int i = 1; i < 5; i++) {
        System.out.print(i + "\t");
        }
        System.out.println();
    for (int i = 5; i < 12; i++) {
        System.out.print(i + "\t");
    }
    System.out.println();
    for (int i = 12; i < 19; i++) {
        System.out.print(i + "\t");
    }
    System.out.println();
    for (int i = 19; i < 26; i++) {
        System.out.print(i + "\t");
    }
    System.out.println();
    
    for (int i = 26; i < 29; i++) {
    System.out.print(i + "\t");
    }
}
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question