السلام عيكم
public class q1 {
public static void main(String args[]) {
int max;
int count = 1;
int a = 0;
Scanner input = new Scanner(System.in);
max = a;
System.out.print("Enter numbers: ");
do {
a = input.nextInt();
if (a > max) {
max = a;
} else if (a == max) {
count++;
}
} while (a != 0);
System.out.printf("The largest number is %d", max);
System.out.printf("%nThe occurrence count of the largest number is %d%n", count);
}
}
import java.util.Scanner;
المشكلة انو لما يحط المستخدم رقم 0 ما إخرج من الـ loop مع انو جميع العملات الا يخرجها صح
مثال على output الصحيح
Sample 1:
Enter numbers: 3 5 2 5 5 5 0
The largest number is 5
The occurrence count of the largest number is 4
(حقي الكود مااسوي كذا يعني لوكتب المستخدم بعد الصفر عدد عادي يكمل ما اخرج من الloop )
فارجو المساعدة وشكرا




