logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Siddharth GuptaStatistics
(/5)

594 Answers

Hire Me
expert
Varun JakkaScience
(/5)

622 Answers

Hire Me
expert
Lawrence BankheadMarketing
(5/5)

627 Answers

Hire Me
expert
Venktesh PrasaadMarketing
(5/5)

891 Answers

Hire Me
Others
(5/5)

Inform the user if the number is a prime number a composite number or neither prime nor composite

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Question 1 (3 pts) Taking the following rules into consideration:

• An integer, greater than 1, that is only divisible by 1 and itself is called a prime number.

• A composite number is a whole number with more than two integer divisors.

• All non-prime numbers greater than 1 are called composite numbers.

• The integers 0 and 1 are neither prime nor composite. • A number cannot be both prime and composite. Write a program that asks the user to input a positive integer. The program should:

1- Check if the value entered is represents a number. If not, the user is prompted to re-enter a valid number (the program should not exit).

2- Inform the user if the number is a prime number, a composite number or neither prime nor composite (the program should not exit).

3- Loop continuously asking the user if they wish to continue (yes/no). If no is entered, the program exits. Hints:

• You need to use a loop. That is, you cannot import a library that has the prime function implemented and use it.

• Only usage of string.isnumeric(), string.isalnum(), string.isdigit() functions is permitted (see instructions page).

• If you use any other approach besides looping, no credit will be given. Sample Interaction: Please enter a positive integer: hello This is not a valid positive integer value. Please re-enter a valid positive integer: -5 This is not a valid positive integer value. Please re-enter a valid positive integer:

5 The number you entered is a prime number. It is not a composite number. Would you like to continue? (yes/no): yes Please enter a positive integer:

6 The number you entered is not a prime number. It is a composite number. Would you like to continue? (yes/no): yes Please enter a positive integer: -

1 This is not a valid positive integer value. Please re-enter a valid positive integer:

2 The number you entered is a prime number. It is not a composite number. Would you like to continue? (yes/no): yes Please enter a positive integer: 199 The number you entered is a prime number. It is not a composite number. Would you like to continue? (yes/no): yes

(5/5)
Attachments:

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme