Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.time.LocalDate;
- import java.time.DayOfWeek;
- public class calendario {
- public static void main (String[] args){
- int ano, mes;
- Scanner leitor = new Scanner(System.in);
- System.out.printf("Ano: ");
- ano = leitor.nextInt();
- System.out.printf("Mes: ");
- mes = leitor.nextInt();
- System.out.println();
- System.out.println("Seg Ter Qua Qui Sex Sab Dom");
- LocalDate data = LocalDate.of(ano, mes, 1);
- DayOfWeek dia = data.getDayOfWeek();
- for (int i=1; i < dia.getValue(); i++){
- System.out.printf(" ");
- }
- while( data.getMonthValue() == mes){
- System.out.printf("%d", data.getDayOfMonth());
- if (data.getDayOfMonth() < 10){
- System.out.printf(" ");
- }else{
- System.out.printf(" ");
- }
- dia = data.getDayOfWeek();
- if (dia.getValue() == 7)
- System.out.println();
- data = data.plusDays(1);
- }
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement