Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone help me with these problems? 1.A pentagonal number is defined as n*(

ID: 674399 • Letter: C

Question

Can someone help me with these problems? 1.A pentagonal number is defined as n*(3n – 1)/2 for n = 1, 2, …, and so on. Therefore, the first few numbers are 1, 5, 12, 22,…

Write a method with the following header that returns a pentagonal number:

public static void getPentagonalNumber (int n)

Write a test program that calls this method to display the first 50 pentagonal numbers with 5 numbers on each line. Use printf to ensure the numbers are aligned to the right.

2.Write a class that contains the following two methods:

public static double celsiusToFahrenheit (double celsius)

public static double fahrenheittoCelsius (double Fahrenheit)

The formula for the conversion is: fahrenheit = (9.0 / 5) * celsius + 32 celsius = (5.0 / 9) * (Fahrenheit – 32)

Write a test program that invokes these methods

3.Write a method that counts the number of letters in a string using the following header:

public static int countLetter tString s)

public static int countDigits (String s)

Write a method that counts the number of digits in a string using the following header: Write a test program that prompts the user to enter a string and displays the number of letters and the number of digits in the string. Please help I am lost

Explanation / Answer

public class PentagonalNumber {

    public static void main(String[] args) {

        for (int i = 1; i <= 100; i++) {

            //System.out.print(getPentagonalNumber(i) + (i %10 == 0? System.getProperty("line.separator") : " ")); //advanced ;D

            System.out.print(getPentagonalNumber(i));

            if (i % 10 == 0) {

                System.out.println();

            } else {

                System.out.print(" ");

            }

        }

    }

    public static int getPentagonalNumber(int n) {

        return (3 * n * n - n) / 2;

    }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote