Write program that will print a pyramid the height of the


1. Write program that will print a pyramid. The height of the pyramid is determined by user input. (See screenshot below for more details). Run your program several times with different height values. Name your program PrintPyramid.java. Use for loop to write program.

2. Write method that will compute the factorial of that integer. In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For instance, factorial of 3 is defined as 3! = 3x2x1 = 6. Factorial of 4 is 4!=4x3x2x1 = 24. If you want to learn more about factorial, you can visit:

https://en.wikipedia.org/wiki/Factorial

Name your method factorial. In your main method, call the factorial method with different parameters. For instance:

int input = 3;

int result = factorial(input );

System.out.println("Factorial of " + input + " is " + result);

input = 5;

result = factorial(input );

System.out.println("Factorial of " + input + " is " + result);

Name your program TestFactorial.java.

3. Take a look at the sample program in Module 3, LeapYear.java. Write method isLeapYear that takes an integer as input parameter, and returns a boolean. In your main method, call the isLeapYear method several times with different values using code similar like below:

int year = 1999;

boolean result = isLeapYear(year);

System.out.println("Is " + year + " a leap year? " + result);

year = 2012;

result = isLeapYear(year);

System.out.println("Is " + year + " a leap year? " + result);

Name your program TestLeapYear.java.

4. Create zip file that contains your Java programs. Include a screenshot of each program execution. You can either paste the screenshot into a Word document or simply paste it into the Comments field when submitting your homework. A sample screenshot of running my programs is attached below:

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Write program that will print a pyramid the height of the
Reference No:- TGS02681487

Now Priced at $20 (50% Discount)

Recommended (95%)

Rated (4.7/5)