Greater than, Less than or Equal to zero (Ver 1)

import java.util.Scanner; public class Main { public static void main(String[] args) { int greatZero, lessZero, zero; greatZero = lessZero = zero = 0; Scanner input = new Scanner(System.in); System.out.println("Enter 10 Numbers:"); for(int i=1; i <= 10 ; i++) { System.out.print(i + "-> "); int numbers = input.nextInt(); if(numbers > 0) { greatZero++; } else if(numbers < 0) { lessZero++; } else { zero++; } } System.out.println(greatZero + " Numbers > 0"); System.out.println(lessZero + " Numbers < 0"); System.out.println(zero + " Numbers = 0"); } }
A program that asks the user to enter 10 integers then the program computes and write how many integers are greater than, less than or equal to 0(zero).

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.