Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Esercizio3 {
- public static void main(String[] args) {
- Scanner leggi=new Scanner (System.in);
- int voto = 0;
- int minimo = -1;
- int massimo = -1;
- int somma = 0;
- int index = 0;
- do
- {
- System.out.print("Inserisci il "+(index++)+" voto");
- voto=leggi.nextInt();
- if (minimo == -1) {
- minimo = voto;
- }
- else {
- if (voto <= minimo && voto != 0) {
- minimo = voto;
- }
- }
- if (massimo == -1) {
- massimo = voto;
- }
- else {
- if (voto >= massimo) {
- massimo = voto;
- }
- }
- somma += voto;
- }while (voto != 0);
- leggi.close();
- System.out.println("IL numero minore" + minimo);
- System.out.println("Il numero maggiore" + massimo);
- System.out.println("La somma è " + somma);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement