1. public class naloga_1 {
  2. public static void main(String[] args) {
  3. int i = 0, n = 0;
  4. try {
  5. String niz = javax.swing.JOptionPane.showInputDialog("Koliko števil želiš obdelati?");
  6. n = Integer.valueOf(niz).intValue();
  7.  
  8. float[] array = new float[n];
  9.  
  10. do {
  11. array[i] = (float)Math.random() * 150 - 100;
  12. i++;
  13. } while(i < n);
  14.  
  15. float vsota = 0;
  16. i--;
  17. while(i >= 0) {
  18. vsota += array[i];
  19. i--;
  20. }
  21.  
  22. System.out.println("Vosta " + n + " zgeneriranih stevil je: " + vsota);
  23. } catch(Exception e) {
  24. System.exit(0);
  25. }
  26.  
  27. System.exit(0);
  28. }
  29. }