I need the solution to this problem in Java format, thank you! 3 Assignment We a
ID: 3754167 • Letter: I
Question
I need the solution to this problem in Java format, thank you! 3 Assignment We are going to write a program that someone who paints the outsides of buildings can use to prepare cost estimates for potential customs. To do so, complete each of the steps below: 1. (5 points) Create a new class named ReportGenerator in the Lab04 project. 2. (5 points) (not autograded) Create class constants for the following values: . The area that can be painted from one can of paint, which is 400 square feet. . The cost of a can of paint, which is $43.50. . The area that an experienced person can paint in an hour, which is 200 square feet What we charge for each hour of labor, which is $50.00. 3. (15 points) You may have noticed that some websites that require you to type in a street address will automatically adjust the address that you enter into some standard format. We are going to do something similar, write a method named tandardizeAddress. It has one formal parameter, which is a String containing an address. It should return a standardized version of the address. Standardization inludes the following steps: . All lowercase letters should be converted to uppercase. . The wordROAD" (with a space in front) should be replaced by the abbreviation RD (including the space). . The word "STREET" should be replaced by the abbreviationST" . The word LANE" should be replaced by the abbreviation LN Name CSCIIG1-(o01,02,03) -Lab 04 Page 2 . The word AVENUE" should be replaced by the abbreviation AVE . The word COURT" should be replaced by the abbreviation CT" You should create a main method that you can use for temporary testing. At the end of the assignmen, y in main with specific contnts. AutoLab will te method with many different parameters, and give you no credit until it does the correct thing with all of themExplanation / Answer
/* I have tried to implement all the steps specified in the question 1, 2 and 3 all in one program. However Point 3 seems to be different than other 2 and have no application of the constants that is declared as per the instruction of step 2. As I am not aware of the LAB 4 as mentioned in question no. 1, It is not clear where those constants will be used. */
/* I have tested many cases for different address, it is working fine. You can change the input in main method to test your input*/
public class ReportGenerator {
public static final double AREA_COVERED_BY_ONE_CAN_PAINT = 400;
public static final double PER_CAN_COST = 43.50;
public static final double AREA_COVERED_BY_PAINT_IN_ONE_HOUR = 200;
public static final double LABOUR_COST_PER_HOUR = 50.00;
public static void main(String[] args) {
String result = standardizeAddress("Avenue road, lane number 6");
System.out.println(result);
}
public static String standardizeAddress(String address){
address = address.toUpperCase();
StringBuilder sb = new StringBuilder();
String str[] = address.split(" ");
String pattern1[] = {"ROAD","STREET","LANE","AVENUE","COURT"};
String pattern2[] = {"ROAD,","STREET,","LANE,","AVENUE,","COURT,"};
String replacement1[] = {"RD","ST","LN","AVE","CT"};
String replacement2[] = {"RD,","ST,","LN,","AVE,","CT,"};
for(int counter1=0; counter1 < str.length ; counter1++){
for(int counter2 = 0; counter2 < pattern1.length ; counter2++){
if(str[counter1].equals(pattern1[counter2])){
str[counter1] = replacement1[counter2];
}else if(str[counter1].equals(pattern2[counter2])){
str[counter1] = replacement2[counter2];
}
}
}
for(int counter = 0 ; counter < str.length ;counter++){
sb.append(str[counter] + " ");
}
return sb.toString().trim();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.