CS 101 - Introduction to Computing, Fall 2013

Lab 9

Due: Tuesday 10/29/2013 by 11:59 pm

For this lab assignment, you are to take an image and create a new image that will show multiple instances of the images stacked one on top of another.

The program in Lect1024c.java may be useful in completing this project. This code repeats part of a picture horizontally two times.

For this lab, you must complete the following:

  1. Prompt the user for a number that will determine the number of times the image gets duplicated.

    To get the user's input, we will use the getIntNumber() method of the SimpleInput class. The SimpleInput class is one of the classes in the bookCAlasses directory. This method will display a "pop-up" window that will prompt the user to enter an integer value.

    The getIntNumber() has two ways it can be used. In either way, it takes a String parameter will be displayed as a message when the user is prompted for the input. That is the only parameter for the first way that getIntNumber() can be used. The other way also takes two more parameter which specify the range the number enter by the user must be in. The following code shows both of these ways.

    // declare in integer variable to store the number entered by the user.
    int value;

    // prompt the user for the number
    value = SimpleInput.getIntNumber ("Please enter an integer value.");

    // display the value entered by the user
    System.out.println ("The user entered: " + value);

    // prompt the user for a number within a range of values
    value = SimpleInput.getIntNumber ("Please enter an integer value between 1 and 10.", 1, 10);

    // display the value entered by the user
    System.out.println ("The user entered: " + value);

    For this lab, you can use either form of the getIntNumber() method that you want. If probably makes sense to use second version of the method. The lower number in the range should be one. Values less than one don't really make any sense. (Perhaps the value of zero could make sense, if you wanted to run the program that didn't create any duplicates of the image. But then why run the program at all?) The upper number in the range could be somewhere around 10, because creating more than 10 duplicates would make the final image quite large.

  2. Your program must prompt the user for the image file to use.

  3. Your program is to duplicate the image the number of times indicated by the integer value given by the user. If we used the flower image, entering the value of 1 would give us:

    Entering the value of 2 would give us:

    Entering the value of 3 would give us:

    Since we are stacking the duplicate images one on top of the next, the width of the new image will be the same as the original image. The height of the new image will be the result of multiplying the height of the original image by the number of duplications we want to create. Thus if the original image had height of 250, the resulting image with 1 duplication would have height of 250 (250 x 1). The resulting image with 2 duplications would have height of 500 (250 x 2). The resulting image with 3 duplications would have height of 750 (250 x 3). The resulting image with 4 duplications would have height of 1000 (250 x 4).

    As we copy the images onto the resulting canvas, we must make sure the Y coordinate of the resulting image would equal to the Y coordinate of the original pixel plus (the height of the image multiplied by a value specifying which copy is being created.

    Your code should add one more NESTED loop to the code used during lectures:

    • If the program is to copy the picture one time, this NESTED loop runs once.
    • If the program is to copy the picture two times, this NESTED loop runs twice.
    • If the program is to copy the picture three times, this NESTED loop runs three time, ect.
  4. Your program must prompt the user for another filename in which the resulting is to be stored.

  5. Be sure to include a comment at the top of your program containing the following information:
    • your name
    • your NET-ID
    • day and time of your CS 101 lab section (i.e. Friday at 9:00)
    • A description of the project.

How assignments should be submitted

You are to submit your program electronically using the link for Lab 9 on the Assignments Page in Blackboard.

-- Main.troy - 2013-10-23

Topic revision: r2 - 2013-10-24 - 17:46:03 - Main.troy
 
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
WISEST
Helping Women Faculty Advance
Funded by NSF