600.108 Intro Programming Lab Week 2 Start with the same partner as last week, but in opposite driver/navigator roles from last week. (See your lab leader if your partner is missing, or if you missed last week.) Remember that only the driver has hands on the keyboard; the navigator's role is to oversee and make suggestions and corrections. You will switch roles after every phase. This week we are going to use different types of phases to write the program. As we did last week, the first phase will still be analysis. However, we are going to skip the pseudocode phase. Instead, we will take an incremental coding approach with three phases of writing and testing parts of the solution (in Java). ------------ PROBLEM STATEMENT: DESKTOP WALLPAPERING ------------- I expect that most of us have customized a computer desktop with a favorite picture at some point. Digital pictures are represented as an array of pixels (picture elements), each with a color. Your computer screen has a resolution which tells you the width (number of columns) and height (number of rows), in pixels, that it uses to display things. Each digital image (picture file) also has a size, which is sometimes given in inches, and sometimes given in pixels. The pixel per inch (PPI) measurement of a digital image is the number of pixels corresponding to an inch (for example, if the picture were to be printed). A higher PPI leads to a better resolution, and the PPI is sometimes referred to as the density of the image. The goal of this program is to calculate the specifics of two different display options for your chosen picture: centering and tiling. In both options the picture will be displayed in its actual size. When centering, the area around the picture will be filled with a solid color (like a mat when framing). When tiling, the picture will be repeated as many times as necessary so that the entire screen is filled. However, the last row and last column of tiles might only contain partial images depending on the measurements. The input to the program must be - the screen resolution in pixels (such as 800 by 600), - the size of the picture in inches (such as 3.5 by 5), - and the picture density in terms of the PPI (such as 80). Using this data, your program will then compute and output: - the size of the picture measured in pixels (width and height), - the total area surrounding the centered picture, measured in square pixels, - the total number of rows and columns (round up) that the image appears in when tiling, - the size of a picture (in inches) that would fill the whole screen given the input density, and - the screen size (resolution in pixels) that would be needed in order for an 8x10 picture with density 1600 PPI to fill the screen. You can assume (and should use test data such) that the screen size is larger than the picture size. You can prompt for the user to enter the input in any order and format that you like. Make sure your program is very user friendly. Include detailed prompts so that the user knows exactly what type of data to input, and nice descriptions on the output. Phase 1) ANALYSIS: First, use paper and pen to draw the problem in a way that makes sense to you. Make sure you understand the geometry and how to do the calculations for a solution. Remember to ask your lab leader if the problem needs clarification. Next, create two full sets of test data. This should include all the input values as well as the resulting output. You can do the calculations by hand or use the calculator accessory. Make up your data so that it demonstrates different situations. Show your samples to a lab leader before proceeding, and add your test data to the file on the display computer when approved. >>> Switch driver/nagivator roles <<< Phase 2) CODING & TESTING: Write a program that prompts for all the input. Then add to the program so that it reads the width and height of the screen. Print the total area of the screen in square pixels. Compile and run your program several times to be sure it works. Show to a lab leader for approval to move on. >>> Switch driver/nagivator roles <<< Phase 3) (more) CODING & TESTING: Add to the program so that it reads the size and resolution of the picture. Print the size of the picture in pixels. Then update the program so that it calculates and prints the total area surrounding the picture when centering is used. Compile and run your program several times to be sure it works. Show to a lab leader for approval to move on. >>> Switch driver/nagivator roles <<< Phase 4) (more) CODING & TESTING: Add to the program so that it calculates and prints the number of rows and columns when tiling is used. Remember to round up so that your output is whole numbers. >>> Switch driver/nagivator roles <<< Phase 5) (final) CODING & TESTING: Add to the program so that it calculates and displays the size of a picture (in inches) that would fill the whole screen. Compile and test. Lastly, add the computation of the screen size needed for an 8x10 at 1600 PPI. Once all the computations are correct, remove the extraneous output (the best way is to make those statements comments) and format the remaining data nicely. Compile and run your program several times to be sure it works. Show to a lab leader for approval to leave. !Yay - you wrote several versions of a program from scratch! ************************************************** MAKE SURE YOU DELETE YOUR FILES OFF THE LAB COMPUTER WHEN DONE!!! FAILURE TO DO SO IS AN ETHICS VIOLATION! (Save on a flash drive or in email first.) **************************************************