Advertisement
Guest User

Untitled

a guest
Sep 17th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.36 KB | None | 0 0
  1. public class NegativeTall {
  2.  
  3.     public static void main(String[] args) {
  4.        
  5.         int[] Tallrekke = {1, 4, 5, -2, -4, 6, 10, 3, -2};
  6.         int negativeTall = 0;
  7.        
  8.         for (int i : Tallrekke)
  9.         {
  10.             if (i < 0) negativeTall++;
  11.         }
  12.        
  13.         System.out.println("Antall negative tall: " + negativeTall);
  14.         // Antall negative tall: 3
  15.         // denne fungerer også...
  16.     }
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement