Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
A pentagonal number is defined as n(3n−1) ∕ 2 for n = 1, 2, . . ., etc.. Therefore, the first few numbers are 1, 5, 12, 22, . . . . Write a method with the following header that returns a pentagonal number:
public static int getPentagonalNumber(int n)
For example, getPentagonalNumber(1) returns 1 and getPentagonalNumber(2) returns 5. In Java, Write a test program that uses this method to display the first 100 pentagonal numbers with 10 numbers on each line. Numbers are separated by exactly one space.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- USING JAVA Create a method that randomly select a letter in the alphabet (the random should be in another method including the main method )arrow_forwardDefine a method findWinningPrize() that takes one integer parameter as the lottery number, and returns the prize as an integer. The prize is returned as follows: If lottery number is 178 or 286, prize is $6000. If lottery number is 296 or 446, prize is $12000. Otherwise, prize is $0. Ex: If the input is 178, then the output is: 6000arrow_forwardPython Only Write a method that prints the fibonnaci sequence containing only evenor odd numbers. Your method should expect two parameters. One thattells you how many numbers of the sequence you want to see and if thenumbers should be even or odd.Example of Even: 0, 2, 8, 34, 144, 610, 2584 ...Example of Odd: 1, 1, 3, 5, 13, 21, 55, 89 ...arrow_forward
- Q3. Create two methods: one that will reverse the order of the digits in an integer and a second determines if a number is a palindrome (i.e. reads the same front to back) using the following method headers. // Method 1: Takes in an integer and reverses it, e.g., reverse(456) returns 654 public static int reverse(int number) // Method 2: Takes in an integer and returns true if it is a palindrome. Use the reverse method you just wrote to implement this method. public static boolean isPalindrome(int number) Create a test program that asks the user to input an integer and provides feedback on whether the integer is a palindrome or not. Hint: To find the reverse number, use one of the following approaches: • Modify your numerical inputs to a string, then use a for loop to reverse the characters with string concatenation and the charAt() method. Retrieve individual digits and combine them in reverse order using the / and % operators, using ten as a divisor. Combine the digits with either…arrow_forwardWrite a method that takes a RegularPolygon as a parameter, sets its number of sides to a random integer between 10 and 20 inclusive, and sets its side length to a random decimal number greater than or equal to 5 and less than 12. Use Math.random() to generate random numbers. This method must be called randomize() and it must take an RegularPolygon parameter. You can call your method in the program's main method so you can test whether it works, but you must remove or comment out the main method before checking your code for a score. You will also need to make sure you do not remove the import statement "import testing.Math" as this is required to check your code for a score.arrow_forwardA pentagonal number is defined as n (3 n-1)/ 2 for n= 1, 2,.. so on. Therefore, the first few numbers are 1, 5, 12, 22, .. Write a method with the following header that returns a pentagonal number: puearrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education