Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JOptionPane;
- public class SumNint {
- {public static void main (String [] args);
- //sommare i primi n numeri interi a partire dal numero uno
- String num = JOptionPane.showInputDialog("Quanti sono i numeri?");
- int conta = 1;
- int somma = 0;
- int valore1 = Integer.parseInt(num);
- {if (valore1 < conta + 1 )
- {
- somma = somma + conta;
- conta = conta + 1;
- }
- else
- JOptionPane.showConfirmDialog(null, somma);
- }
- }}
Add Comment
Please, Sign In to add comment