Advertisement
Guest User

esercizio3

a guest
Jan 13th, 2021
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Esercizio3 {
  4.  
  5. public static void main(String[] args) {
  6. Scanner leggi=new Scanner (System.in);
  7. int voto = 0;
  8. int minimo = -1;
  9. int massimo = -1;
  10. int somma = 0;
  11. int index = 0;
  12.  
  13. do
  14. {
  15. System.out.print("Inserisci il "+(index++)+" voto");
  16. voto=leggi.nextInt();
  17. if (minimo == -1) {
  18. minimo = voto;
  19. }
  20. else {
  21. if (voto <= minimo && voto != 0) {
  22. minimo = voto;
  23. }
  24. }
  25. if (massimo == -1) {
  26. massimo = voto;
  27. }
  28. else {
  29. if (voto >= massimo) {
  30. massimo = voto;
  31. }
  32. }
  33. somma += voto;
  34. }while (voto != 0);
  35.  
  36. leggi.close();
  37.  
  38. System.out.println("IL numero minore" + minimo);
  39. System.out.println("Il numero maggiore" + massimo);
  40. System.out.println("La somma è " + somma);
  41.  
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement