A prime number id a number that can be evenly divided by only itself and 1. Writ
ID: 3642117 • Letter: A
Question
A prime number id a number that can be evenly divided by only itself and 1. Write a Boolean function named IsPrime which takes an integer as an arguement and returns True if the arguement is a prime number or false otherwise. use the function in an application that lets the user enter a number and then displays a message indicating whether the number is prime.tip: recall that the MOD operator divides one number by another and returns the remainder of the division. in an expression such as intNum1 MOD intNum2, the MOD operator will return 0 if intNum1 is evenly divisible by intNum2.
Explanation / Answer
package util; import java.util.Scanner; public class PrimeNo { public static void main(String args[]) { int num = 0; String text = ""; Scanner s = new Scanner(System.in); System.out.println("Enter the number"); num = s.nextInt(); int i; for (i = 2; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.