Write program that will print a pyramid

Assignment Help Basic Computer Science
Reference no: EM131885996

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:

Reference no: EM131885996

Questions Cloud

What infrastructural or cyber domain sector are protected : According to your answer above, what infrastructural or cyber domain sector or assets are being protected by such enforcement?
What is the purpose of the preamble in ethernet frame : What is the content of SOF (1 byte)? What is the purpose of the preamble in Ethernet frame?
Assessing the efficiency of common techniques : Assess the efficiency of common techniques for effectively communicating compensation and benefit plans to employees. Support your answer.
Where are there breaches of ethical behavior : Choose an ethical issue to write about. You may choose from the list below or, with approval from the instructor, select a different socially-relevant topic.
Write program that will print a pyramid : Write program that will print a pyramid. The height of the pyramid is determined by user input. (See screenshot below for more details).
Introduction to sql server database : We all use cash machines or at least are familiar with them. Most of them are connected to a relational database like SQL Server.
What is the advantage of having the cli : What is the advantage of having the CLI especially when it comes to troubleshooting?
How can school counselors respect the wishes : How can school counselors respect those wishes and yet still serve adolescent students who want to discuss family matters with them without parental knowledge?
Identify the seven domains within your diagram : Identify the 7 domains within your diagram. Identify the IP address, subnet mask and default gateway for the devices. Workstations you can provide a range.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Mutually exclusive investment opportunities

XYZ Corporation is faced with two mutually exclusive investment opportunities. The cost of capital is 12 percent. The cash flows for the two projects are:

  Discuss the integrity checking code into methods

H. V. Jagadish and Xiaolei Qian. "Integrity Maintenance in an Object-Oriented Database." Proc. 18th International Conference on Very Large Data Bases.

  Define the function-template definition

The template parameters of a function-template definition are used to specify the types of the arguments to the function.

  Unauthorized network access to obtain information

Is it acceptable for the U.S. government to support unauthorized network access to obtain information about other countries including terrorist activities?

  Design a comparison-based algorithm for sorting array

Design a comparison-based algorithm for sorting a four-element array with the smallest number of element comparisons possible.

  Design and specify an adt for this collection of data

Imagine you are working for a geologist who has records for earthquakes that occurred during the past 50 years. Each record includes a date, location, strength, and duration. Design and specify an ADT for this collection of data.

  Determining the reflection dialogue

In at least 150 words Looking back at the information you have studied and the knowledge you have gained in this course, evaluate your own competencies and identify two areas that you will pursue because of what you learned. Examples are mergers a..

  Two unsigned integer as input

Write a program that take two unsigned integer as input. Then convert into binary its binary number and perform AND , OR , XOR and XNOR operation.

  Create the needed constructors

In this assignment you will be implementing three classes -Date (you would reuse the Date class after implementing toString() and equals() method), Employee and EmployeeTest with main method to test Employee class.

  Roles that must be performed in a procurement organization

What are some other roles that must be performed in a procurement organization, whether they are each performed by a single person or all performed by the same person?

  How can people prepare for certification

Detailed course objectives, training guides, sample test questions, chat rooms, and discussion groups often are included. Individuals also set up Web sites to offer their own views and tips on the testing process.

  What is the projected increase in retained earnings

The profit margin is 6.0 percent and the firm has a 30 percent dividend payout ratio. What is the projected increase in retained earnings?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd