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

  Determine how task management is achieved in that context

Task management for OO systems can be quite complex. Do some research of OOD methods for real-time systems (e.g., [BIH92] or [DOU99]) and determine how task management is achieved in that context.

  The most essential in developing an input design

Explain what principle you believe is the MOST essential in developing an input design, and justify your choice.

  What are five mathematical operators

How is it possible that Access can use dates in calculations - What are five mathematical operators available for use in Access calculated fields?

  Digikey or newark distributor sites

Go on the internet, eg. the Amazon site, or the Digikey or Newark distributor sites, and read up on three types of Arduino shields used with the Arduino Uno. Explain what type of projects each shield is used with.

  Write sql statements to display the values of any rows

Assume that these functional dependencies are true and that the data have been corrected, as necessary, to reflect them. Write all SQL statements necessary to redesign this table into a set of tables in BCNF and 4NF. Assume that the table has data..

  Determine the temperature drop during this process

Refrigerant-134a is throttled from the saturated liquid state at 700 kPa to a pressure of 160 kPa. Determine the temperature drop during this process and the final specific volume of the refrigerant.

  Implications of implementing form of internet working

You will research the differences between LAN, MAN and WAN and describe the implications of implementing each form of internet working.

  Construct a relative frequency distribution

Construct a relative frequency distribution for the 50 observations, and compare this with the probability distribution obtained in the previous exercise.

  Compute the expected one-year inflation rates

Using the expectations theory, compute the expected one-year inflation rates in (a) the second year (Year 2 only) and (b) the third year (Year 3 only).

  Propose a modification to the delivery mechanism

Propose a modification to the delivery mechanism that does allow for reversibility. Your mechanism should not require giving all switches globally unique names.

  Modify the current algorithm

Modify the current algorithm so that while it adheres to the basic template distribution idea, it does not add multiple extra spaces to a location before there has been one extra space added to each location.

  Create a version of this game using alice

Remember the six Ps of programming-Proper Prior Planning Prevents Poor Programming. Take the time to design your world before you build it.

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