Please help me, its emergency!!!

The 10 numbers will be collected from the keypad using a loop. If the number entered is a prime only, that number will be added. How do I write a Java program to input 10 prime numbers and print the sum?

I expect you know how to build a loop reading input values.

The question is, how to find the primes.
All you have to do is test to see whether the number has any factors less than its square root (since the other factor will be greater)

A simple example for this can be found at

https://www.programmingsimplified.com/java/source-code/java-program-print-prime-numbers

You will find that google is very useful for turning up java code for almost anything you want to do.

Sure, I can help you write a Java program to solve your problem!

To check if a number is prime or not, you can use a function that loops from 2 up to the square root of the number and check for any divisors. If no divisors are found, the number is prime.

Here's an example Java program that collects 10 prime numbers from the keypad and prints their sum:

```java
import java.util.Scanner;

public class PrimeNumberSum {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

int count = 0; // Number of prime numbers collected
int sum = 0; // Sum of the prime numbers

System.out.println("Enter 10 prime numbers:");

while (count < 10) {
int number = scanner.nextInt();

if (isPrime(number)) {
sum += number;
count++;
}
}

System.out.println("Sum of the prime numbers is: " + sum);
}

// Function to check if a number is prime
public static boolean isPrime(int num) {
if (num <= 1) {
return false;
}

for (int i = 2; i <= Math.sqrt(num); i++) {
if (num % i == 0) {
return false;
}
}

return true;
}
}
```

In this program, we use a `while` loop to keep collecting numbers until we have collected 10 prime numbers. Each number entered is checked using the `isPrime` function, and if it is prime, it is added to the `sum` variable and the `count` is incremented.

Hope this helps!