@bokomoko/

Calcula dia das mães

Java

No description

fork
loading
Files
  • Main.java

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.4129319980100059","path":"Main.java","file":{"path":"Main.java","content":{"asEncoding":{"base64":"aW1wb3J0IGphdmEudGltZS5Mb2NhbERhdGU7CgpjbGFzcyBNYWluIHsKCiAgcHVibGljIHN0YXRpYyBMb2NhbERhdGUgZGlhRGFzTcOjZXMoIGludCBhbm8gKSB7CiAgICBMb2NhbERhdGUgcHJpbWVpcm9EZU1haW8gPSBMb2NhbERhdGUub2YoYW5vLCA1LCAxKTsKICAgIGludCBxZGlhID0gcHJpbWVpcm9EZU1haW8uZ2V0RGF5T2ZXZWVrKCkuZ2V0VmFsdWUoKTsKICAgIHJldHVybiAoIHByaW1laXJvRGVNYWlvLnBsdXNEYXlzKDE0LXFkaWEpKTsKICAgIAogIH07CiAgLyogcHJvZ3JhbWEgcHJpbmNpcGFsCiAgdmFpIGNhbGN1bGFyIHF1ZSBkaWEgY2FpIG8gZGlhIGRhcyBtw6NlcyBudW0gY2VydG8gCiAgYW5vLgogICovIAogIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKICAgIFN5c3RlbS5vdXQucHJpbnRsbigiTGlzdGEgZGUgRGF0YXMgZG9zIGRpYXMgZGEgbcOjZXMgZGVzZGUgMjAwMCIpOwogICAgU3lzdGVtLm91dC5wcmludGxuKCJBbm8gIERhdGEgICAgICAgRGlhIGRhIFNlbWFuYSIpOwogICAgZm9yIChpbnQgcXVhbF9hbm8gPSAyMDAwO3F1YWxfYW5vPD0yMDI1O3F1YWxfYW5vKyspewogICAgICBMb2NhbERhdGUgZGlhID0gZGlhRGFzTcOjZXMocXVhbF9hbm8pOwogICAgICBTeXN0ZW0ub3V0LnByaW50bG4ocXVhbF9hbm8rIiAiK2RpYSArICIgIitkaWEuZ2V0RGF5T2ZXZWVrKCkpIDsKICAgIH0KICB9Cn0="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.time.LocalDate;

class Main {

  public static LocalDate diaDasMães( int ano ) {
    LocalDate primeiroDeMaio = LocalDate.of(ano, 5, 1);
    int qdia = primeiroDeMaio.getDayOfWeek().getValue();
    return ( primeiroDeMaio.plusDays(14-qdia));
    
  };
  /* programa principal
  vai calcular que dia cai o dia das mães num certo 
  ano.
  */ 
  public static void main(String[] args) {
    System.out.println("Lista de Datas dos dias da mães desde 2000");
    System.out.println("Ano  Data       Dia da Semana");
    for (int qual_ano = 2000;qual_ano<=2025;qual_ano++){
      LocalDate dia = diaDasMães(qual_ano);
      System.out.println(qual_ano+" "+dia + " "+dia.getDayOfWeek()) ;
    }
  }
}