Advertisement
apez1

Term 1: Lesson 34 - Coding Activity 6

Nov 28th, 2018
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.math.*;
  3.  
  4. public class Lesson_34_Activity_Six {
  5.    
  6.     static Scanner scanner = new Scanner(System.in);
  7.    
  8.     public static boolean allPositive(int a[]) {
  9.         int check = 0;
  10.        
  11.         for(int i = 0; i < a.length;i++) {
  12.             if(a[i] < 0) {
  13.                 check = 1;
  14.             }  
  15.         }
  16.        
  17.         if(check == 1 ) {
  18.             return false;
  19.         }
  20.         return true;
  21.            
  22.        
  23.        
  24.     }
  25.  
  26.    
  27.  
  28.     public static void main(String[] args) {   
  29.    
  30.     int a[] = {-1,2,3,4,5};
  31.    
  32.     boolean x = allPositive(a);
  33.    
  34.     System.out.println(x);
  35.    
  36.    
  37.    
  38.     }
  39.    
  40.    
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement