14-12-2011, 11:15 AM
|
#8
|
تاريخ التسجيل: Oct 2010
التخصص: CS بإذن واحد أحد
نوع الدراسة: إنتظام
المستوى: الثالث
الجنس: ذكر
المشاركات: 29
|
رد: Cpcs 202 شروحات وحلول وواجبات الجافا
كود:
import java.util.Scanner;
public class HAct3 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter numbers [Entering 0 exits the program]: ");
int n = in.nextInt();
int count = 1, max = 0;
for (; ;) {
if (n == 0)
break;
if (n > max) {
max = n;
count = 0;
}
if (n == max)
count++;
System.out.print("Enter numbers [Entering 0 exits the program]: ");
n = in.nextInt();
}
System.out.println("\nThe largest number is " + max);
System.out.print("The occurrence count of the largest number is " + count);
}
}
:)
|
|
|
|
|