/** * Desktop wallpapering program. */ import java.util.Scanner; /** This program is the solution for week 3 of java lab. */ public class Wallpaper { /** * This program's main method performs all the work for the problem. * @param args is not used here. */ public static void main(String[] args) { Scanner kb = new Scanner(System.in); int screenWidth, screenHeight; double picWidth, picHeight; int ppi; double matArea; final int fWidth = 8; // frame width final int fHeight = 10; // frame height final int fppi = 1600; // frame pixels per inch System.out.print("Enter screen width and height in pixels: "); screenWidth = kb.nextInt(); screenHeight = kb.nextInt(); System.out.println("Total screen area is " + screenWidth * screenHeight + " pixels"); System.out.print("Enter picture width and height in inches: "); picWidth = kb.nextDouble(); picHeight = kb.nextDouble(); System.out.print("Enter ppi: "); ppi = kb.nextInt(); picWidth = Math.ceil(picWidth * ppi); // convert from inches to pixels picHeight = Math.ceil(picHeight * ppi); // convert from inches to pixels System.out.println("Picture width and height in pixels: " + picWidth + " " + picHeight); matArea = screenWidth * screenHeight - picWidth * picHeight; System.out.println("The total mat area is " + matArea + " square pixels"); System.out.println("Tiling will have " + (int) Math.ceil(screenHeight / picHeight) + " rows and " + (int) Math.ceil(screenWidth / picWidth) + " columns"); System.out.println("A picture would have to be " + (double) screenWidth / ppi + " inches wide by " + (double) screenHeight / ppi + " inches tall to take up the whole screen."); System.out.println("An 8x10 picture at 1600 ppi would need a " + (fWidth * fppi) + " pixels wide by " + (fHeight * fppi) + " pixels high screen to completely fit"); } }