Testing a leap year library

Assignment Help JAVA Programming
Reference no: EM13879014

1. Write a program Checkerboard.java that takes an integer command-line argument N, and uses two nested for loops to print an N-by-N "checkerboard" pattern like the one below: a total of N2 asterisks, where each row has 2N characters (alternating between asterisks and spaces).

The following are sample executions of the program, with the expected output.> java Checkerboard 4
* * * *
* * * *
* * * *
* * * *

> java Checkerboard 5
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *

2. Testing a Leap Year library.

This exercise is about code testing. You are given a ready-made library that has some ‘deliberate bugs'. Your task is to prove that by collecting the evidence (i.e. finding for which input the code produces an incorrect output.)

The code to be tested is provided in class form (i.e. you do not have access to the source code). Thus you are asked to implement black-box testing.

This is how you use the LeapYear code from command line:

> java LeapYear
Usage: 'java LeapYear <year>' (where 'year' is a valid integer in [- 1000 to 9999])

> java LeapYear 2015 false

Now, your task is to write a separate class, name it TestLeapYear and store it in a file named TestLeapYear.java, that will extensively test the LeapYear program and produce the evidence showing that it does not work for all possible input.

You are advised to start by extending the code below (make sure you use the same folder as LeapYear.class):

public class TestLeapYear
{
public static void main(String[] args)
{
boolean isLeap = LeapYear.isLeapYear(2015);
if(isLeap) // we know year 2015 is not a leap year, so we expect a false
{
System.out.println("2015 -> True: Something is wrong!");
}
else
{
System.out.println("2015 -> False: Seems to work ok!");
}
}
}

Submission guidelines/checklist

- You should submit your assignment in electronic form via Blackboard.

- You should name every program as suggested, e.g. Quadratic.java

- The header of your program should include comments with the author name (yourself) & email, a quick description of the program, and any other details that you would like me to know (e.g. whether it compiles, how far you got in your assignment, etc.).

- You should also include comments in the code where appropriate (there is no need for excessive use of comments, but add them where they add clarity).

- Use the coding conventions and readability suggestions discussed in the lectures.

- In your communications, use your UCLAN email exclusively (other email addresses like hotmail, live, gmail, etc.) will be ignored.

- When uploading your submission, make sure you do not forget to attach your programs.

- The submitted programs should be the result of your own personal work. You can look-up the lecture slides, the textbook and even the Web for examples. But you need to be ready to defend your solutions verbally, and even reproduce them on your own in exam conditions.

- Exercises that do not compile are marked up to 40% max. Exercises that do not always produce the desired output or include unnecessary complexity are marked up to 60% max. Exercises that do not use correct styling, coding conventions, appropriate variable naming and comments, are marked up to 80% max. Failing to follow these guidelines will also affect your mark.

Reference no: EM13879014

Questions Cloud

Problem regarding the normal shock stands : Air flows through a duct as in Fig P9.84, where A1 = 24 cm2, A2 = 18 cm2, and A3 = 32 cm2. A normal shock stands at section 2.
The air force ignored marketing costs : Alameda Instruments (AI) has offered to supply the Air Force with computer monitors at cost plus 20 percent.
Calculate optimal price, and profit for organization : Assuming that the firm acts as a monopolist, calculate the optimal price, quantity, and profit (i.e., TR - TC) for the organization. After using algebra to find the solution, present your results graphically.
What are the benefits and costs of fdi to the host country? : What are the benefits and costs of FDI to the host country?
Testing a leap year library : Write a program Checkerboard.java that takes an integer command-line argument N, and uses two nested for loops to print an N-by-N "checkerboard" pattern
Determine the moment of that force : A mechanic uses a piece of pipe AB as a lever when tightening an alternator belt. When he pushes down at A, a force of 580 N is exerted on the alternator B. Determine the moment of that force about bolt C if its line of action passes through O.
Write paper about hatshepsut : Write a a 3-4 pages paper about "Hatshepsut" c. 1473 - 1458 B.C. (18th Dynasty)
Determine the marginal cost of milk production : How have total revenues changed if the actual total production of milk remains unchanged?
Critically analyse the possible effects of e-commerce : Examine the extent to which the role and nature of management accountants might differ within the public and private sectors. Critically analyse the possible effects of e-commerce on the role of the manage- ment accountant.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write the method in java

2.char mostOftenIn(String s) that for a given string s, returns the character that occurs most often in s.

  Design an adt for the problem

Design an ADT for this problem. Be sure to consider all necessary operations to maintain the appointment book for one year, to archive the yearly book and create a new book for the following year.

  Draw a uml diagram of each of the shapes

Draw a UML diagram of each of the Shapes, Rectangle and Square classes using the code that has been provided. Complete this using the examples that have been provide in the lecture slides.

  Question 1a give explanation why it is significant to

question 1a give explanation why it is significant to follow web engineering principles taking into account how the web

  Design and construct a computer program

Design and construct a computer program in one of the approved languages (C, C++, Java, Pascal, etc.) that will illustrate the use of a third-order explicit Runge-Kutta method of your own design.

  Quadratic that solves quadratic equations

Write a method called quadratic that solves quadratic equations and prints their roots. Recall that a quadratic equation is a polynomial equation in terms of a variable x of the form ax2 + bx + c = 0. The formula for solving a quadratic equation is ?..

  Write java program to accept two words as input

Write a Java program that accepts two words as input and determines if one of them is resulting from changing the order of the others' letters.

  You must also do the work of sorting

You must also do the work of sorting in the method. You cannot just call another library method. Use loops to show the data in the original array as well as the repopulated array in ascending order.

  Implement a java program that generates the receipt

Create a Receipt class that could be used by an automobile parts store. Items to include as data members are receipt number date of purchase, customer number, customer name and address, customer phone number, item number, description, unit price, ..

  What ways can vulnerable inmates be protected

What ways can vulnerable inmates be protected? Why are classification and housing assignments so critical to these populations?

  Problem related to java programming

Question 1: Explain why NO_EXIT has been declared and used in defining the contents of the map array, rather than just directly using the value 99999 in the map array definition. Question 2: What is the value stored in map[2][1]? What is the inter..

  Create a java class called student

Create a Java class called student with the following instance variables: private String studentName

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