subject

Write a program that prompts the user to enter in a positive number. Only accept positive numbers - if the user supplies a negative number or zero you should re-prompt them. Next, determine if the given number is a prime number. A prime number is a number that has no positive divisors other than 1 and itself. For example, 5 is prime because the only numbers that evenly divide into 5 are 1 and 5. 6, however, is not prime because 1, 2, 3 and 6 are all divisors of 6.
Here's a sample running of the program:
Enter a positive number to test: 5
2 is NOT a divisor of 5...
3 is NOT a divisor of 5...
4 is NOT a divisor of 5...
5 is a prime number!
And here's another running:
Enter a positive number to test: 9
2 is NOT a divisor of 9...
3 is a divisor of 9...
9 is NOT a prime number.
Some notes on your program:
1 is technically not a prime number.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:00
What are the most likely causes of conflict at the meeting? check all that apply.
Answers: 1
question
Computers and Technology, 22.06.2019 20:40
Assume that there is a 4% rate of disk drive failure in a year. a. if all your computer data is stored on a hard disk drive with a copy stored on a second hard disk drive, what is the probability that during a year, you can avoid catastrophe with at least one working drive? b. if copies of all your computer data are stored on three independent hard disk drives, what is the probability that during a year, you can avoid catastrophe with at least one working drive?
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
To become an audio technician, the most successful tactics might include the following. (select all that apply). learning how to persuade other people gaining different types of experience in audio technology learning as much as possible about art history establishing a reputation as a reliable professional
Answers: 1
question
Computers and Technology, 23.06.2019 18:00
File account.java (see previous exercise) contains a definition for a simple bank account class with methods to withdraw, deposit, get the balance and account number, and return a string representation. note that the constructor for this class creates a random account number. save this class to your directory and study it to see how it works. then write the following additional code: 1. suppose the bank wants to keep track of how many accounts exist. a. declare a private static integer variable numaccounts to hold this value. like all instance and static variables, it will be initialized (to 0, since it’s an int) automatically. b. add code to the constructor to increment this variable every time an account is created. c. add a static method getnumaccounts that returns the total number of accounts. think about why this method should be static - its information is not related to any particular account. d. file testaccounts1.java contains a simple program that creates the specified number of bank accounts then uses the getnumaccounts method to find how many accounts were created. save it to your directory, then use it to test your modified account class.
Answers: 3
You know the right answer?
Write a program that prompts the user to enter in a positive number. Only accept positive numbers -...
Questions
question
Mathematics, 04.10.2021 03:00
question
Mathematics, 04.10.2021 03:00
question
Mathematics, 04.10.2021 03:00
question
English, 04.10.2021 03:00
question
Health, 04.10.2021 03:00
question
Geography, 04.10.2021 03:00
Questions on the website: 13722360