Attachment 'Bisestile.java'
Download 1 import javax.swing.JOptionPane;
2
3
4 public class Bisestile {
5
6 public static void main(String[] args) {
7
8 int anno=0;
9
10 String valore=JOptionPane.showInputDialog("Inserisci l'anno");
11
12 try {
13 anno = Integer.parseInt(valore);
14 } catch (NumberFormatException e)
15 {
16 JOptionPane.showMessageDialog(null, "Problema nella conversione");
17 }
18
19 if(anno%4==0)
20 {
21 if(anno%100 != 0)
22 {
23 JOptionPane.showMessageDialog(null,"L'anno è bisestile" );
24 }
25 else
26 {
27 if(anno%400==0)
28 {
29 JOptionPane.showMessageDialog(null,"L'anno è bisestile" );
30 }
31 else
32 {
33 JOptionPane.showMessageDialog(null,"L'anno non è bisestile" );
34
35 }
36
37 }
38
39
40 }
41 else
42 {
43 JOptionPane.showMessageDialog(null, "L'anno "+anno+" non è bisestile");
44 }
45 }
46 }
Attached Files
You are not allowed to attach a file to this page.