QuestionQuestion

Fundamentals of Computer Science I
Laboratory Assignment #3
Learning Objectives:
• Exploring BlueJ IDE with Java SE 8 (JDK)
• Program Testing
In this lab, you will continue your practice with BlueJ IDE – edit, compile, link and execute reasonable size Java programs. You will also develop skills in program testing. You will also write the code for a small method. Consult the additional handouts provided as when necessary.
0. Read the handout titled Program Testing. Consider the leap year problem stated in the handout. Develop test cases along the lines indicated. Do not proceed to the next step before completing this step.
1. Create a BlueJ project named LAB03 as follows:
a. Open the P drive and create a folder named BlueJ, if it does not exist already. Under this folder, create another subfolder named CSC203 for this course, if it does not exist already.
b. Launch BlueJ and create a BlueJ project named LAB03 under the CSC203 folder mentioned in the previous step.
c. Create a class named MyCalendar. Open the editor and delete all the code placed in it automatically by BlueJ. Choose Options and Preferences and then check Display Line Numbers. Also, choose the options Class and Page Setup... and set the Orientation to Landscape. Use a web browser, access the class site on Blackboard, locate the file named MyCalendar.java, open it, copy and then paste it as code for the class MyCalendar.
d. Create a new class named LeapYearTester. Open the editor and delete all the code placed in it automatically by BlueJ. Use a web browser, access the class site on Blackboard, locate the file named LeapYearTester.java, open it, copy and then paste it as code for the class LeapYearTester.
e. Compile the LeapYearTester code. If there are errors, edit the code carefully and ensure that it compiles successfully. There should be none. Observe that MyCalendar class is also automatically compiled. In the project window, move the two classes around a bit to show clearly their relationship.
f. Now we are ready to test the program. In the Project Window showing the classes, select the option View and then select Show Terminal Window. In the terminal Window, choose Options and select Unlimited buffering and Clear screen at method call. Thus, the terminal window is automatically cleared when the LeapYearTester is executed and the terminal window retains all test cases however many there are.
g. Test the program carefully on all test cases you have developed. Since the code for one of the methods is incomplete, the output will be wrong in some cases. At this stage, your job is to certify whether or not the program given works correctly. Complete the test case table prepared. Do not attempt to fix the logical error(s) at this stage.
h. Attempt this step only after completing the test case table as required in Step g. As stated already, the program will not produce the correct output for all cases since the code for the method nextLeapYear in the MyCalendar class is incomplete. Now complete the code. It requires a few lines that are left blank in the code. Be sure to test the program for all cases again, not just the ones for which it failed earlier, because you may have introduced additional logical errors.
i. After you are sure the program works fine and the output is what you need, clear the terminal window, run all test cases above systematically.
j. In the Project Window showing the classes, select the option Project and then select Page Setup. Choose Landscape.
• The project window showing the class diagrams as Lab03Class.pdf
• The source code for LeapYearTester as LeapYearTester.pdf
• The source code for MyCalendar as MyCalendar.pdf

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

/**
* This program reads an integer, checks if it is a leap year,
* and, if not, prints the next leap year.
*
* The current rule for computing leap years was formulated
* by Pope Gregory XIII only in 1582.
*

*/
import java.util.*;
public class LeapYearTester
{
    public static void main (String[] args)
    {
       char response; // user response to continue or not
       int year;      // input year
       int newYear;   // next leap year computed
       Scanner input = new Scanner (System.in); // to read user input
      
       // display purpose and author
       System.out.println ("This program reads an integer, checks if "
            + "it is a leap year, ");
       System.out.println ("and, if not, prints the next leap year.");
       System.out.println (); // print blank line
       System.out.println ("Author: Kad Lakshmanan\tVersion: January 24, 2018");
       System.out.println (); // print blank line

       // prompt to see if user wants to run the program
       System.out.print ("Want to run? (enter y to run): ");
       response = input.next().charAt(0);
       System.out.println (); // print blank line

       while (response == 'y' || response == 'Y') {
            System.out.print ("Enter a year > 1582: ");
            year = input.nextInt();
            // process if year > 1582
            if (year > 1582) {
                if (MyCalendar.isLeapYear(year))
                   System.out.println (year + " is a leap...

By purchasing this solution you'll be able to access the following files:
Solution.zip, Solution.docx and Solution.zip.

50% discount

Hours
Minutes
Seconds
$35.00 $17.50
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats