Problem Description : Palindromes are words or numbers that are read the same forwards and backwards....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Problem Description : Palindromes are words or numbers that are read the same forwards and backwards. For example: 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 101, 111, 121 are palindrome numbers. Prime numbers are the numbers that are dividable by only one and by themselves. For example: 2, 3, 5, 7, 11, 13, 17, 19, 23 are prime numbers. Develop an algorithm and then translate it to a Java program to prompt user for an integer number, n. The program should print all prime palindrome numbers less than or equal to n. For example: 2, 3, 5, 7, 11, 101 are all palindrome prime numbers less than 102. Use top-down design, and divide the problem into appropriate sub-problems. You should develop following methods and use them in your program: Takes a positive integer number as it argument, and returns true if n is a prime number, otherwise returns false. public static boolean is_prime(int n) { } Takes a positive integer number as it argument, and returns true if n is a palindrome number, otherwise returns false. public static boolean is_palindrome(int n) { } Develop other methods that you need to finish your lab assignment. Notes: 1. The body of the main program should be very simple, and it should call appropriate methods to do the task. 2. We have not studied Strings and arrays yet, so you should not use them to solve this problem. 3. Design and develop numerical methods to solve the problem. 4. Use javadoc style comment and comment the class and methods. Part B: [10 marks] Develop body of the even2odd(int n) that takes an integer number as an argument and changes all even digits of the number to odd digits by adding one to each odd digit. The method should return the result as an integer number. The class Lab5B.java is partially developed. Develop body of the even2odd (int n) method. public class Lab5B{ public static void main(String [] args) { // Sample test case: int n=26540; System.out.println("n= System.out.println("n= } n=9528; "+n+", ans= "+even2odd (n)); "+n+", ans= "+even2odd (n)); Part B: [10 marks] Develop body of the even2odd(int n) that takes an integer number as an argument and changes all even digits of the number to odd digits by adding one to each odd digit. The method should return the result as an integer number. The class Lab5B.java is partially developed. Develop body of the even2odd (int n) method. } public class Lab5B{ public static void main (String[] args) { // Sample test case: int n=26540; System.out.println("n= System.out.println("n= } n=9528; /** } changes all even digits of argument to odd digits by adding 1 to each digits @param n: a positive integer number @return the result as an integer number */ public static int even2odd (int n) { "+n+", ans= "+even2odd (n)); "+n+", ans= "+even2odd (n)); int ans=0; //your goes here. return ans; examples for function call: n= 26540, ans= 37551 n= 9528, ans= 9539 Problem Description : Palindromes are words or numbers that are read the same forwards and backwards. For example: 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 101, 111, 121 are palindrome numbers. Prime numbers are the numbers that are dividable by only one and by themselves. For example: 2, 3, 5, 7, 11, 13, 17, 19, 23 are prime numbers. Develop an algorithm and then translate it to a Java program to prompt user for an integer number, n. The program should print all prime palindrome numbers less than or equal to n. For example: 2, 3, 5, 7, 11, 101 are all palindrome prime numbers less than 102. Use top-down design, and divide the problem into appropriate sub-problems. You should develop following methods and use them in your program: Takes a positive integer number as it argument, and returns true if n is a prime number, otherwise returns false. public static boolean is_prime(int n) { } Takes a positive integer number as it argument, and returns true if n is a palindrome number, otherwise returns false. public static boolean is_palindrome(int n) { } Develop other methods that you need to finish your lab assignment. Notes: 1. The body of the main program should be very simple, and it should call appropriate methods to do the task. 2. We have not studied Strings and arrays yet, so you should not use them to solve this problem. 3. Design and develop numerical methods to solve the problem. 4. Use javadoc style comment and comment the class and methods. Part B: [10 marks] Develop body of the even2odd(int n) that takes an integer number as an argument and changes all even digits of the number to odd digits by adding one to each odd digit. The method should return the result as an integer number. The class Lab5B.java is partially developed. Develop body of the even2odd (int n) method. public class Lab5B{ public static void main(String [] args) { // Sample test case: int n=26540; System.out.println("n= System.out.println("n= } n=9528; "+n+", ans= "+even2odd (n)); "+n+", ans= "+even2odd (n)); Part B: [10 marks] Develop body of the even2odd(int n) that takes an integer number as an argument and changes all even digits of the number to odd digits by adding one to each odd digit. The method should return the result as an integer number. The class Lab5B.java is partially developed. Develop body of the even2odd (int n) method. } public class Lab5B{ public static void main (String[] args) { // Sample test case: int n=26540; System.out.println("n= System.out.println("n= } n=9528; /** } changes all even digits of argument to odd digits by adding 1 to each digits @param n: a positive integer number @return the result as an integer number */ public static int even2odd (int n) { "+n+", ans= "+even2odd (n)); "+n+", ans= "+even2odd (n)); int ans=0; //your goes here. return ans; examples for function call: n= 26540, ans= 37551 n= 9528, ans= 9539
Expert Answer:
Answer rating: 100% (QA)
import javautilScanner public class PrimePalindrome public static boolean isprimeint n ... View the full answer
Related Book For
College Algebra
ISBN: 978-0134697024
12th edition
Authors: Margaret L. Lial, John Hornsby, David I. Schneider, Callie Daniels
Posted Date:
Students also viewed these programming questions
-
answer all questions as instructed below. attend all questions. 4 Computer Vision (a) Explain why such a tiny number of 2D Gabor wavelets as shown in this sequence are so efficient at representing...
-
1.The purpose of using a balanced scorecard is for: Multiple Choice A.companies to make sure their business activities align with strategy. B.companies to compare themselves with their competitors....
-
Condensed statement of financial position and income statement data for Clarence Limited appear below. CLARENCE LIMITED Statements of Financial Position December 31 CLARENCE LIMITED Income Statement...
-
The income statement of Tamarisk, Inc. for the month of July shows net income of $ 2 9 0 0 based on the Service Revenue of 6 7 0 0 , Salaries and Wages expense 2 4 0 0 , Supplies expense 1 0 0 0 ,...
-
In addition to the size variables, we also have information on several binary variables. The variable URBAN is used to indicate the facility's location. It is one if the facility is located in an...
-
Why does technical analysis receive little support from academically oriented students of investments?
-
A linear time-invariant filter is described by the difference equation y[n] = x[n]+x[n-1] x[n - 3] - x[n 4] (a) Derive a simple expression for H(), the frequency response of this system. (b) Sketch...
-
Draw a flowchart, using Microsoft Visio or LucidChart, to document the logic required to complete this program. Save the flowchart as a PDF file. Develop a C++ program, following the logic in your...
-
We want to electroplate all surfaces of a solid steel rod which is 300 mm long and 10 mm in diameter. We want a plating thickness of 1.00 mm. Our current is 20 Amps, and the plating material has a...
-
A steam of liquid water at 300 K Pa and 20 is mixed in an adiabatic (Q=0.0) mixing chamber with steam at 300 K Pa and 250 , which is entering at rate of 90 kg/s. The mixture is to leave as a...
-
What is the percentage increase in the theoretical power in wind when wind speed increases from 9 m/s to 10 m/s?
-
What is the future value of $3,617, given a discount rate of 8.6% and a time of 19 years?
-
A heating system that uses hot steam has a total heating load of 503 thousand btuh. How much heated Steam flow in pounds per hour ( lb/hr ) is required to satisfy the total load?
-
The article "Why Good Accountants do Bad Audits" referred to an experiment where two people were given the same information about a motorcycle accident. One person was then assigned to pay the role...
-
Baxter, Inc., owns 90 percent of Wisconsin, Inc., and 20 percent of Cleveland Company. Wisconsin, in turn, holds 60 percent of Clevelands outstanding stock. No excess amortization resulted from these...
-
A small company took out three loans totaling $25,000. The company was able to borrow some of the money at 4% interest. It borrowed $2000 more than one-half the amount of the 4% loan at 6%, and the...
-
Graph the parabola. In Exercises, give the domain, range, vertex, and axis of symmetry. In Exercises, give the domain, range, focus, directrix, and axis of symmetry. x = 5y 2 - 5y + 3
-
Simplify the expression. Assume all variables represent nonzero real numbers. 2.
-
A lot of compensation information is available to employees today on the Web (e.g., www.salary.com), and much of it is inaccurate. How can an organization assure employees that they are fairly...
-
Flexible benefit plans are common today. Discuss ways in which employers can ensure that employees make good choices about the benefits and benefit levels that they choose within the benefits...
-
Payroll and benefits are commonly outsourced. Discuss which parts of PM, compensation, benefits, and payroll you would consider outsourcing; justifying your views.
Study smarter with the SolutionInn App