CS46A Fall 19

4A

The Wallpaper Pros company hangs wallpaper in small offices. The offices have one door and no window. Each office is rectangular. The walls are always 8 feet tall. The door way is 80 inches tall by 32 inches wide. A roll of wallpaper costs $40 and is 27 inches wide 33 feet long. Wallpaper Pros charges $1.10 per square foot for labor plus the cost of the paper. All four walls (minus the door) and the ceiling are covered with wallpaper.

Write a WallpaperJob class to model a wallpapering job for Wallpaper Pros

WallpaperJob has a constructor that takes the length and width of the room (in that order).

Provide these methods:

Provide Javadoc

You will need to convert the square inches to square feet. There are 144 square inches in a square foot. You must use a constant.

Here are some constants you must use

public static final int SQ_INCHES_PER_SQ_FOOT = 144;
public static final double WALL_HEIGHT_IN_FEET = 8;
public static final double DOOR_HEIGHT_IN_INCHES = 80;
public static final double DOOR_WIDTH_IN_INCHES = 32;

You also need to define and use constants for the number of inches in a foot, the cost of labor per square foot, the cost of a roll of wallpaper, and the width and length of the roll of paper.. Make these constants accessible to any class. (public static final ...) Don't use any magic numbers in the code.

For the draft, define the constants and instance variables. Write the constructor and the setDimensions, getLength and getWidth methods. Provide Javadoc for these methods and constructor and the class itself.

4A draft:
4A final:

4B

Write an application WallpaperJobInvoice. (It will have a main method.) WallpaperJobInvoice will print an invoice for a wallpaper job from 4a.

  1. Create a Scanner and ask for the client's name using this exact prompt: System.out.print("Enter the name of the client: " );
  2. Get the clients name. It may be more than one word
  3. Using the same Scanner, ask the user for the length of the room to be papered using this exact prompt: System.out.print("Enter the length of the room: "); Then get the length,
  4. Using the same Scanner, ask the user for the width of the room using this exact prompt: System.out.print("Enter the width of the room: "); Then get the width
  5. Instantiate a WallpaperJob using the class you wrote in 4a using the length and width the user entered
  6. Print "Wallpaper Pros" (That is the name of the company)
  7. On the next line, print the client's name.
  8. On the next line print "Total cost: " followed by the cost for this job.
  9. Now print the total cost one more time on a separate line.

For the draft, do steps 1,2. 6, and 7

For the final, you will need to submit WallpaperJob again here, but do not make any changes to it.

4B draft:
4B final:

4C

Updated instructions 9/15

Write an application StringsAndThings. (It will need a main method.)

Create a Scanner object and do the following.

Hint: To get just the first name, you need to know the index of the first space. You can find the index of the first space with the indexOf method. str.indexOf(" ") will return the index of the first space or -1 if there are no spaces in str. You can assume there is at least one space so you do not need to worry about -1 for this problem. After you find the index of the fist space, you can use substring to get the first name.

Only create one Scanner.

For the draft, create the Scanner and do the first three steps

4C draft: (new URL 9/15)
4C final: