Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package it.uniba.itps.lab_inf.AA10.appelli.N00.M622841;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args)
- {
- Scanner in = new Scanner(System.in);
- final int LIMITE_SX_GIORNO = 0;
- final int LIMITE_DX_GIORNO = 32;
- final int LIMITE_SX_MESE =0;
- final int LIMITE_DX_MESE =13;
- String MONTH;
- String YEAR;
- String DAY;
- boolean sentinella = true;
- boolean data = false;
- do
- {
- //PUNTO 1:
- // ACQUISISCI DALLO STANDARD INPUT UNA STRINGA DAY:
- System.out.println("Inserisci il giorno: ");
- DAY = in.next();
- // PUNTO 2:
- // Se DAY = “STOP” termina.
- if (DAY.compareToIgnoreCase("STOP") == 0)
- {
- System.out.println("IL PROGRAMMA VERRA' TERMINATO...");
- sentinella = true;
- }
- // PUNTO 3:
- // Acquisisce dallo standard input due stringhe MONTH e YEAR:
- else
- {
- System.out.println("Inserisci il mese: ");
- MONTH = in.next();
- System.out.println("Inserisci l'anno: ");
- YEAR = in.next();
- //PUNTO 4:
- // Converte in numero le tre stringhe lette:
- int GIORNO = Integer.parseInt(DAY);
- int MESE = Integer.parseInt(MONTH);
- int ANNO = Integer.parseInt(YEAR);
- //PUNTO 5:
- // Se la terna di numeri non rappresenta una data valida allora emette nello
- //standard output la stringa “ERRORE” e ricomincia l'acquisizione (passo 1.)
- if(GIORNO <= LIMITE_SX_GIORNO || GIORNO >= LIMITE_DX_GIORNO)
- {
- System.out.println("ERRORE GIORNO!!!");
- data = false;
- }
- else if( MESE <= LIMITE_SX_MESE || MESE >= LIMITE_DX_MESE)
- {
- System.out.println("ERRORE MESE !!!");
- data = false;
- }
- else if( ANNO <= 0)
- {
- System.out.println("ERRORE ANNO!!!");
- data = false;
- }
- else
- {
- data = true;
- }
- int output = CalendarUtils.weekOfDay(GIORNO, MESE, ANNO);
- if(output == -1)
- {
- System.out.println("NON GREGORIANO!!!");
- }
- else
- {
- switch(output)
- {
- case 1: System.out.println("LUNEDI");break;
- case 2: System.out.println("MARTEDI");break;
- case 3: System.out.println("MERCOLEDI");break;
- case 4: System.out.println("GIOVEDI");break;
- case 5: System.out.println("VENERDI");break;
- case 6: System.out.println("SABATO");break;
- case 7: System.out.println("DOMENICA");break;
- default: System.out.println("BOH");
- }
- data = false;
- }
- }
- }
- while(!sentinella || !data); // false
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement