Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Print Positives of array

import java.util.Scanner;
public class PrintPositives {
    public static void main(String[] args) {
        System.out.println("Enter size of array ");
        Scanner input = new Scanner(System.in);
        int arr = input.nextInt();
        int[] numbers = new int[arr];
        for (int i = 0; i < numbers.length; i++) {
            System.out.println("Please enter number");
            numbers[i] = input.nextInt();
        }
        System.out.println("positive numbers");
        for (int i = 0; i < numbers.length; i++) {
            if (numbers[i]>=0){
                System.out.println("positive" + "-" + numbers[i]);
            }
        }
    }
}
Comment

Print positive numbers from array

public class NumPositives {
    public static void main(String[] args) {
        double a[] = {-4,5,7,-9};
        System.out.println("positive numbers");
        for (int i = 0; i < a.length; i++) {
            if (a[i]>=0){
                System.out.println("positive" + "-" + a[i]);
            }
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: how to add value in jcombobox in java 
Java :: java initialise array in return 
Java :: trémaux’ method java 
Java :: fail if condition not met in java if condition 
Java :: get action command in java 
Java :: activity show 1 time in android studio java 2022 
Java :: Pattern using recursion in Java 
Java :: java manajro 
Java :: encode é to é java 
Java :: how to increase a variable once java 
Java :: Java double Keyword 
Java :: generate infinity steam java 
Java :: Java Numbers and Strings 
Java :: fill two dimension array java 
Java :: java get parent process name 
Java :: newinstance in java giving exception 
Java :: naming convention for selenium java automation 
Java :: java binary search tree 
Java :: what are abstract classes in java 
Java :: java arrow function 
Java :: print treeset java 
Java :: enum to string java 
Java :: java calling a method 
Java :: remove java ubuntu 20.04 
Java :: print outputstream to console java 
Java :: graph with dependies problem 
Sql :: foreign key set 0 
Sql :: mysql status 
Sql :: find duplicates mysql column 
Sql :: SELECT list is not in GROUP BY clause 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =