Question
Purpose: 1. More practice using the Scanner object for reading input. 2. More practice with the Code, Compile, Debug process. 3. Practice with if and
Purpose: 1. More practice using the Scanner object for reading input. 2. More practice with the Code, Compile, Debug process. 3. Practice with if and if-else statements. 4. Practice with loops. 5. Practice using an array. 6. Introduction to using methods. 7. Introduction to documenting methods using Javadoc comment blocks. Deliverables (submitted to Blackboard): 1. Completed program submission template with pre-programming responses, Java code, and program input/output. Instruction: 1. Download the program submission template and answer pre-programming questions. 2. Create new project, Lab10. Create new package, lab10. Create new class, Main. 3. Study the example code below which is a program that finds the reverse of a given positive integer. A number that is the reverse of itself is known as a Palindrome integer. A prime number that is also a Palindrome is called a Palindromic prime. Write a program that finds the first 100 Palindromic primes. Display the numbers, ten to a line. Here is the first twenty: --- The first 20 Palindromic primes: 2 3 5 7 11 101 131 151 181 191 313 353 373 383 727 757 787 797 919 929 --- 4. The program should make use of four methods with the following declarations: public static int reverseInt(int number) public static boolean isPalindrome(int number) public static boolean isPrime(int number) public static boolean isPalindromicPrime(int number) The methods should be commented using the Javadoc convention as shown in the example program 5. Comment your code sufficiently, including a block comment above Main with your name, the current date, and our globalid. See the example code for a reference. 6. Run the code and test it with the input and output sample. Correct any errors. 7. Copy and paste your code, Main.java, to the second page of the program submission template. 8. Copy and paste your output to the third page of the program submission template. 9. Save as Lab10.docx and attach to Blackboard assignment for submission. CPS 180 Lab 10 11-16-2017 Sample: package lab10; import java.util.Scanner; /* * This program reverses a positive integer that the user provides. * Demonstrates Javadoc comment block for method. Begin with "/**". */ /* * Date: 11/16/2017 */ public class Example { /** * Returns an integer that is the reverse of the argument. * @param number a positive integer * @return the reverse of number */ public static int reverseInt(int number) { int reverse = 0; while (number > 0) { reverse = reverse*10 + number%10; number = number/10; } return reverse; } public static void main(String[] args) { int n = 0; int r = 0;; // Initialize scanner for input. Scanner input = new Scanner(System.in); System.out.println("Reverse Integer:"); // Prompt user for number of employees. System.out.print("Enter a positive integer: "); n = input.nextInt(); input.close(); // Call function to get its reverse. r = reverseInt(n); // Display results. System.out.printf("The reverse of %d is %d. ", n, r); } }
PLEASE DO NOT ANSWER.I HAVE A NEW QUESTION UP THAT IS EASIER TO UNDERSTAND
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started