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
Why is it difficult to correctly identify a new product as emerging technology
Gekata [30.6K]
Because a lot of people post false information on websites and marketing managers (whatever they're called) will actually falsely advertise their product as using new technology.
5 0
4 years ago
Several surprising findings were revealed in the wake of the Target breach, providing a cautionary tale for all executives and s
Akimi4 [234]

Answer: (a) Target had security software, but the notification alerts from the software were  ignored.

Explanation:

The security software was there in target but its notification alerts being ignored was something which was not thought to have been occurred during the Target security breach, as anyone could be alerted with the notification alert.

6 0
3 years ago
What are the design concepts and assumptions behind a class, an object and the relationship between them? What are the roles met
Triss [41]

Answer:

Object-oriented programming (OOP) is a procedural language and based on classes associated with an object. Without classes and object relationship OOP is not possible. According to program's design concept classes provide abstraction and encapsulation with the help of object. Object have states and behaviors like cat has states like name, color and  cat has also behaviors like  wagging the tail, eating, jumping etc. A class forms template or blueprints for these states and behaviors because different cats have different behaviors and states.

Methods provide a way for encapsulation and accessing private class members with public methods and static fields are sometimes best alternative for global variable. We can use static field when it same for all and shared by all objects of that class and it can save memory because we do not have to initialize it for each object

8 0
3 years ago
True or False: Cracking a Vigenère cipher with brute force takes longer than a Caesar cipher, but it is still a reliable method
iragen [17]

Answer:

False

Explanation:

The Vigenere cipher is an encryption method that uses a series of interwoven Ceaser ciphers and a keyword to encrypt text. The difference between this cipher and the Ceaser cipher is the tabular interwoven Ceaser cipher and the keyword.

Multiple keywords can be used in the Vigenere cipher. The use of this keyword makes the brute-force decipher algorithm unreliable for decoding text encrypted with it.

7 0
3 years ago
a department chair decides to change a little-used computer lab into a lounge so that students will interact more between classe
tekilochka [14]

Option D discursive and planned is the correct option.

Which of the following best describes the organizational hierarchy system of communication?

It is a multi-tiered structure of reporting levels and system checks provided for a regular flow of information between managers and employees.

What is the meaning of discursive writing?

Well, a discursive essay is a genre of writing that asks you to investigate a topic; gather, read and evaluate evidence; and present a position on your topic based on the evidence gathered.

What is an example of planned change?

The introduction of employee welfare measures, changes in the incentive system, introduction of new products and technologies, organizational restructuring, team building, enhancing employee communication, as well as technical expertise, fall under the category of Planned Change.

What are the three types of change give examples.

Ackerman (1997) has distinguished between three types of change:

Developmental – May be either planned or emergent; it is first order, or incremental. ...

Transitional – Seeks to achieve a known desired state that is different from the existing one. ...

Transformational – Is radical or second-order in nature.

Thus , option D is the correct option:

To know more about planned changes:

brainly.com/question/25594630

#SPJ4

3 0
1 year ago
Other questions:
  • Suppose that the first number of a sequence is x, where x is an integer. Define ; ‍ if is even; ‍ ‍ ‍ if is odd. Then there exis
    11·1 answer
  • What is the biggest type of gear?<br><br>A. Spur<br>B.Worm<br>C.Wheel<br>D.Pinion
    6·2 answers
  • Please I need this answer now.<br>this is the fill in the blanks​
    14·1 answer
  • Which tool is used to plan a web site?<br> HTML<br> Storyboard<br> Text editor<br> WYSIWYG
    5·2 answers
  • A user purchased a new smart home device with embedded software and connected the device to a home network. The user then regist
    5·1 answer
  • Pixar is a company that creates a huge amount of images, audio recordings, and videos, and they need to decide what compression
    11·1 answer
  • Create five circles like the Olympic Rings. fill them with the colors given below
    8·1 answer
  • Technician A says that a camshaft must open and close each valve at exactly the right time relative to piston position. Technici
    11·1 answer
  • You can put ______ on your phone.
    10·1 answer
  • List at least three kinds of harm a company could experience from electronic espionage or unauthorized viewing of confidential c
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!