1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
MrMuchimi
3 years ago
14

Write a function name isPrime, which takes an integer as an argument and returns true if the argument is a prime number, or fals

e otherwise. Demonstrate the function in a complete program that prompts for a number and indicates whether or not it is prime.
Computers and Technology
1 answer:
pishuonlain [190]3 years ago
8 0

Answer:

public static boolean isPrime(int number)

   {

       if(number<1)

           return false;

       else if (number == 1||number ==2 ||number==3)

       {

           return true;

       }

       else

       {

           for(int i=2; i<number; i++)

           {

               if(number%i==0)

                   return false;

           }

           return true;

       }

   }

The complete program is given in the explanation section

Explanation:

import java.util.Scanner;

public class PrimeNumber {

   public static boolean isPrime(int number)

   {

       if(number<1)

           return false;

       else if (number == 1||number ==2 ||number==3)

       {

           return true;

       }

       else

       {

           for(int i=2; i<number; i++)

           {

               if(number%i==0)

                   return false;

           }

           return true;

       }

   }

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter a number to check if it is Prime");

       int num = in.nextInt();

       if(isPrime(num)){

           System.out.println("The number "+num+" is a prime number");

       }

       else {

           System.out.println("The number "+num+" is NOT a prime number");

       }

   }

}

Prime numbers are numbers divisible only by themselves and 1 Examples are: (2, 3, 5, 7, 11)

You might be interested in
Rob is planning his housewarming party. He wants to design an invitation and personalize it for each invitee. He needs to create
lara31 [8.8K]

Answer:

1: Word Processor

2: Graphics Software

3: Mail Merge

Explanation:

Given

1. Create a list of invitees

2. Design an invitation card

3. Personalize the card

Creating a list of invitees is a task that requires basic activities such as typing, using of numbers and bullets; these activities can be achieved using word processing software programs such as Microsoft Word, WordPerfect, amongst others.

<em>So task 1 requires a word processor</em>

An invitation card is a piece of graphics that can be perfectly handled by graphics software programs such as CorelDraw, Adobe Photoshop, etc.

<em>So task 1 requires a graphics software</em>

Task 3 can be achieved using mail merge and this is because mail merge can be used either to print or to mail recipients. While mailing the recipients, one can easily personalize each letter (or in this case, an invitation card) to suit the recipient it is being directed to.

5 0
3 years ago
What is the answer ??​
Anna11 [10]

Answer:

option 1 is correct go with 1s .

3 0
3 years ago
Which of the following is the BEST example of the principle of least privilege? Correct Answer: Wanda has been given access to t
pishuonlain [190]

Answer: Wanda has been given access to the files that she needs for her job.

Explanation:

The principle of least privilege is when a user is only given the minimum level of permissions that he or she needs to perform a particular job function. This helps in reducing the risk of attackers having access to data.

The best example of the principle of least privilege is Wanda has been given access to the files that she needs for her job. Given access to all of the file servers or access to all of the files on one server is incorrect.

7 0
3 years ago
Which of the following help departments organize unique access controls for access to folders and data files within a department
never [62]

Answer:

B. Role-based access controls

Explanation:

Roll-based access control is a way to control access to the network and to data which depends on the position of employees in a department. This way the permission to access information are granted according to roles that are assigned to employees. This type of access control allows access privileges to employees only to the folders and data files which they need in order to perform their tasks and it does not allow them to access the data or information which is not relevant to them. This helps the department to secure the sensitive information and data files and reduces the risk of data breaches.

6 0
3 years ago
Readability is the level of vocabulary used on the page. True or false
konstantin123 [22]

Answer:

FALSE....john has no idea what hes talking about. i knew this was false yet i looked it up and got it wrong anyway because of john its freaking false

Explanation:

8 0
3 years ago
Other questions:
  • Who controls communication ethics?
    13·1 answer
  • Create a class called Home that contains 4 pieces of information as instance variables: county (datatype string), street (dataty
    5·1 answer
  • How much does a tech person get each year?
    11·2 answers
  • Describe the GRANT statement and explain how it relates to security. What types of privileges may be granted? How are they revok
    15·1 answer
  • Sandra wants to have her new technology up and running as soon as possible. She is looking for a tool that she can
    8·1 answer
  • RrayList Mystery Consider the following method:
    9·1 answer
  • Write a Java program that prompts the user for an int n. You can assume that 1 ≤ n ≤ 9. Your program should use embedded for loo
    5·1 answer
  • Please answer<br><br>NO LINKS​
    7·1 answer
  • Can you help me with Computer issues graphic organizer?<br> Will give out brainly
    6·1 answer
  • 2
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!