Question: Question 6. (question6.java) (10 marks) (7 marks) Write a program that prompts for an integer input (assume the user enters a positive integer, you don't

 Question 6. (question6.java) (10 marks) (7 marks) Write a program that

Question 6. (question6.java) (10 marks) (7 marks) Write a program that prompts for an integer input (assume the user enters a positive integer, you don't need to do input checking this time). Compute and display all of the prime numbers up to and including that integer. Remember, a prime number is a number that is only divisible by 1 and itself. You'll need two loops here - my recommendation is a for loop that goes from 1 to the integer that was requested. For each number in that range you need to test all of the numbers that could be divided into that number and check the remainder. For a prime number, only 1 and the number itself should produce a remainder of zero -ifany other number produces a remainder of zero then it is divisible and not prime. java question6 Enter an integer value: 20 Prime numbers: 13 17 19. java question6 Enter an integer value: 1000 Prime numbers: 2 .. more numbers not displayed here 983 991 997 (3 marks) Two things for these marks. 1. Take two integers as inputs and check only for the prime numbers between the two digits. 2. Make sure your program is efficient-you don't need to check all of the possible divisors so have your loop end when you've checked enough of them to ensure the number is prime (this is not shown in the output but will be checked when marking). java question6 Enter two integer values: 10 20 Prime numbers

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!