Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

MUST BE IN C++ LANGUAGE. NO BUILT IN FUNCTIONS. CAN ONLY USE !!!!******* You may not use any header files other than iostream or any

MUST BE IN C++ LANGUAGE. NO BUILT IN FUNCTIONS. CAN ONLY USE !!!!******* You may not use any header files other than iostream or any built-in functions.**

For this assignment you are to implement two prime number functions that are then used to implement a larger program. One of the prime number function isprime() tests integer values to determine if they are prime. The prototype for the function is:

bool isprime(int num);

This function tests the value of num to determine if it is a prime number. If num is prime, then the function returns true, otherwise it returns the value false.

The second prime number function, having the prototype

int prime(int n);

returns the nth prime number, where 2 is the first prime, 3, the second, 5 the third, and so on.

Using the two prime number functions you are to then implement a program that repeatedly offers the user the following three menu options:

F: Find the nth prime number

T: Test a value to see if it is prime

Q: Terminate the program

The user selects an option by entering the associated letter, in uppercase or lowercase. Any other input should lead to a prompting of the user for a correct input. Depending on the option selected by the user program should perform the action described in the following.

In response to an input of F the program prompts the user to enter a positive (greater than 0) value. If a valid value is input, then the program, treating that value as its ordinal number equivalent, should output the prime number corresponding to that value. For example, an input value of one should result in the output of 2, the first prime number; an input of 2 results in the output of 3; and so on. If the user inputs an invalid number value (i.e., zero or a negative number) the program should output an appropriate error message, but take no additional action for the F option

For an input value of T the program prompts the user to enter a non-negative value (i.e., a value that is greater than or equal to zero), after which the program outputs a message indicating whether or not the input value is prime. The program responds to an invalid value with an appropriate message, and no additional action for the T option.

An input of Q causes the program to terminate.

NO BUILT IN FUNCTIONS. CAN ONLY USE !!!!*******

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students explore these related Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 3 weeks ago