Question: Part D. An application from math: Prime numbers. 1 and 2 are the same as last week. If you already did them, you can go

Part D. An application from math: Prime numbers. 1 and 2 are the same as last week. If you already did them, you can go straight to 3. A prime number is a number whose only divisors are 1 and itself. So we know that 7 is prime because none of 2, 3, 4, 5, or 6 divide evenly into 7. Write a program that prompts the user for a number, and then tests whether that number is prime. Your program should print out the result. You must use a for loop. 1. Write pseudocode to do this. If youre feeling stuck, try to think of how you would check if a number is prime using paper and pencil, then try to think of how you would automate that process. Check your answer with one of the lab teachers before moving on, and get your checklist signed. 2. Translate your pseudocode from 1 into C++ code. Copy-paste your code into your lab report. Run your code with several outputs to be sure its right before moving on. 3. Using what youve already done, write pseudocode for a function bool isprime(int n) that returns true if n is prime, and false if its not. Check your answer with one of the lab teachers before moving on, and get your checklist signed. 4. Translate your pseudocode from 3 into C++ code, adding a sensible main function. Copy-paste your code into your lab report. Run your code with several outputs to be sure its right before moving on.

5. Change your main function to prompt the user to enter numbers over and over, telling them if theyre prime. You should have a way for the user to tell you they want to stop entering numbers. You can go straight to C++ for this one. Copy-paste your code into your lab report. Run your code with several outputs to be sure its right.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!