4A
The Student Painters Company paints dorm rooms . The rooms have one window and one door. The room is rectangular. The walls are always 8 feet tall. The door way is 80 inches tall by 32 inches wide and the window is 4 feet by 5 feet. Student Painters charge $100 for labor plus the cost of the paint to paint a room. A gallon of paint cost $31.95 and will cover 300 square feet. All four walls (minus the window and door) and the ceiling are painted.
Write a PaintJob
class to model a paint job for Student Painters.
PaintJob
has a constructor that takes the length and width of the room given as doubles (in that order).
public PaintJob(double length, double width)
Do not do any calculations in the constructor. Just initialize the instance variables.Provide these methods:
public double getLength()
Gets the length of the room in this PaintJobpublic double getWidth()
Gets the width of the room to paintpublic void setDimensions(double theLength, double theWidth)
sets a new length and width for the roompublic double getSurfaceArea()
Gets the surface area to paint. (Does not include the area of the door or window.) public double getCostOfPaint()
Gets the cost of the paint for the job. Do not calculate surface area in this method. Call getSurfaceArea()
Charge for the factional gallons use. The left over paint can be used on another jobpublic double getJobCost()
Gets the cost of this PaintJob
. Do not calculate surface area or the cost of the paint in this method. Call other methods in the class.Provide Javadoc
You will need to convert the square inches for the door to square feet. There are 144 square inches in a square foot.
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;
public static final double WINDOW_HEIGHT_IN_FEET = 5;
public static final double WINDOW_WIDTH_IN_FEET = 4;
You need to define and use constants for the cost of labor, the cost of a gallon of paint, and the number of square feet a gallon will cover. 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: (new URL as of 2/3/2017)
4B
Write an application InputPractice
. (It will need a main method.)
Create a Scanner
object and do the following.
Only create one Scanner
.
For the draft, create the Scanner and do the first two steps
4C
Many people like to have things like towels, shirts, and glassware personalized with the letters of their initials. You are to write a class Letters
which represents a person's initials. An Letters
class has instance variables of a first name, middle initial (one letter. No period), and last name.
There is no starter file. You will write the whole class.
The Letters
class has two constructors (This is called overloading).
public Letters(String theFirst, String theMiddleInitial, String theLast)
initializes the instance variables with the values of the parameters. (In the draft you can assume theMiddleInitial will be exactly 1 character long. For the final use just the first letter - using substring)public Letters(String theFirst, String theLast)
initializes the first and last names to the given parameters and initializes the middle initial to the empty String (two double quotes with no space like this "")Letters
class has these methods
public String getFirstName()
public String getMiddleInitial()
public String getLastName()
public int characterCount()
the number of characters in the full name - not counting spacespublic String getFullName()
gets the full name with spaces separating the names. Note: When the there is no middle initial, there will be 2 spaces between first and last name. That is okay.public String getLetters()
gets the letters comprising the initials (first initial, middle initial, last initial) with no spacesDo not use an if statement. You do not need it.
Provide full Javadoc (the class, the constructors, and the methods)
To get the first letter of a string, you can use substring
String firstLetter = word.substring(0, 1);
For the draft, provide the instance variables and the first constructor. Implement these methods: getFirstName
, getMiddleInitial
, and getLastName
methods. Implement the other methods as stubs. Provide Javadoc. For the stubs, indicate what will be returned in the final not null.