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....
-
Dowell Hardware reported cost of goods sold as follows. Dowell made two errors: 1. 2016 ending inventory was overstated by $2,000. 2. 2017 ending inventory was understated by $5,000. Instructions...
-
can you help write a budgetery plan for a staffing agency along with ideas on budget planning and controls along with 2 sample budgets ( Cash and Selling and Administrative ) thank you
-
Hansons Furniture Outlet reported the following comparative income statement for the years ended June 30, 2010 and 2009. During 2010, Hansons Furniture Outlet discovered that the 2009 ending...
-
Warf Computers, Inc., was founded 15 years ago by Nick Warf, a computer programmer. The small initial investment to start the company was made by Nick and his friends. Over the years, this same group...
-
Do the good guys win? Can a corporation that practices corporate social responsibility (CSR) win over one that focuses on profits only? What are some advantages of spending money on CSR?
-
The graph above represents various flows that can occur through a sewage treatment plant with the numbers on the arcs representing the maximum flow (in tons of sewage per hour) that can be...
-
Calculate net income given the following information: shares outstanding = 1,000,000; stock price = $18/share; PE ratio = 20. A. $750,000 B. $800,000 C. $850,000 D. $900,000 E. $950,000
-
Solve the equation. Write the solution set with the exact values given in terms of natural or common logarithms. Also give approximate solutions to 4 decimal places, if necessary. 3 3 x 3 = 2 5 x 4
-
simplify your answer 5 x + 8 x-4
-
Solve the equation. (5.651)(x) = (42)(x)(-9.3) - 164.78
-
Luthan Company uses a plantwide predetermined overhead rate of $23.40 per direct labor-hour. This predetermined rate was based on a cost formula that estimated $257,400 of total manufacturing...
-
Solve the following g(x)=1+ 4x- 7x - 5x Be sure that no value in your list appears more than once. 0,0,...
-
Draw the structure of (1,1-dimethylethyl)cyclopentane.
-
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.
-
The heat of vaporization of ether is \(25.98 \mathrm{~kJ} / \mathrm{mol}\) at its boiling point, \(34.5^{\circ} \mathrm{C}\). (a) Calculate the rate of change of vapour pressure with temperature...
-
Show that the internal energy of an ideal gas is a function only of temperature.
-
For a gas obeying the equation of state \(V=B+\frac{R T}{P}\), the Joule-Thomson coefficient is given by \[ \mu_{\mathrm{JT}}=-\frac{1}{C_{P}}\left(T \frac{d B}{d T}-B ight) \]
Study smarter with the SolutionInn App