import java.util.Scanner;
public class nomor1 {
public static void main (String []args) {
Integer genap,ganjil,positiv,negatif,nilai,total;
Scanner input = new Scanner(System.in);
genap=0;
ganjil=0;
positiv=0;
negatif=0;
total=0;
do {
System.out.print("Nilai : ");
nilai=input.nextInt();
if (nilai%2==0)
genap++;
else
ganjil++;
if (nilai>0)
positiv++;
else
negatif++;
total++;
} while (nilai!=0);
System.out.printf("\nBanyaknya Bilangan Ganjil : %d\n", ganjil);
System.out.printf("Banyaknya Bilangan Genap : %d\n", genap-1);
System.out.printf("Banyaknya Bilangan Positiv : %d\n", positiv);
System.out.printf("Banyaknya Bilangan Negatif : %d\n", negatif-1);
System.out.printf("Total Banyaknya Bilangan : %d\n", total-1);
System.out.printf("\n");
}
}
Contoh Outputnya :
0 komentar:
Posting Komentar