Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

sboard Content,jsplooursed 142473 18content jd 11137653 Lab #1 Programming Exerc

ID: 3741896 • Letter: S

Question

sboard Content,jsplooursed 142473 18content jd 11137653 Lab #1 Programming Exercise Once your code is complete, you may proceed to Submit Lab 18 link in which you will attach your coding project The objectives of this lab assignment are as follows Declare variables Display variable values Format floating point data Use arithmetc operators . Use the newline escape sequence e Create named constants. Accept console input Convert or parse from string input to numerc data. Assignment User Story: As a user I want an application that will llow me to calculate the total cost for the irstallation phus the materials for a wood floor huving Acceptance Criteria: User will be prompted to enter the length, width and per square foot wood cost for a flooring installation The application will calculate the total square feet length times width The application will calculate the total materials cost: total square feet times per square foot wood cost The application will define two constant variables: cost per hour- $35,75 and number of square feet that can be installed per hour- 40 The applikation will calculate the number of hours required for installation total square feet divided by install feet per hour e The application will calculate the total installation labor cost number of hours required for installation times cost per hour The application will display the relevant data therough a mixture of string literals and properly formatted numeric data (see example output below Technical Requirements The application will display the programmer's name The cost per hour and number of square feet that can be instaled per hour must both be defined as constant variables. Length and width values will be entered by the user as integers The per square foot wood cost well be entered by the uver as a double data type All moneylcost values must be properly formatted as currenxy with the dollar sign . The newine escape sequence must be used in a least one output line Example Output ocan Temporary avid's Flooring Cost Estinator lease enter length of floor: 75 lease enter width of floor: 15 lease enter the cost per square foot for the flooring selected: 5.01 or a total floor size of 1125 the flooring cost is: $5,636.25 It will take 28.13 hours to install the floor at a cost of $1,ees.47 The total finished cost for the new floor is: $6,641.72

Explanation / Answer

FloorInstallationCost.java

//package declaration
package woodfloor;
//importing package
import java.util.Scanner;
//class declaration
public class FloorInstallationCost {
//declaring constant variables
static final double COST_PER_HOUR=35.75;
static final int INSTALLED_PER_HOUR=40;
//main function to be executed
public static void main(String[] args) {
//declaring variable
int length, breadth, size;
double costPerSquareFoot, materialCost,laborCost,totalCost, totalTime;
//Creating object for taking user input from command line
Scanner in=new Scanner(System.in);
//Printing the company name and using escape character
System.out.println("You_Name Flooring Cost estimators ");
//asking user for the length of the floor
System.out.print("Please enter the length of the floor:");
//storing the user input
length=in.nextInt();
//asking user for the breadth of the floor
System.out.print("Please enter the breadth of the floor:");
//storing the user input
breadth=in.nextInt();
//asking user for the cost per square feet of the floor
System.out.print("Please enter the cost per square feet of the flooring selected:");
//storing the user input
costPerSquareFoot=in.nextDouble();
//calculating size of the floor
size=length*breadth;
//calculating the material cost
materialCost=size*costPerSquareFoot;
//calculating time required for completing wooden flooring
totalTime=(double)size/INSTALLED_PER_HOUR;
//calculating the labour cost of the flooring
laborCost=totalTime*COST_PER_HOUR;
//calculating total cost of the flooring which includes material and labour cost
totalCost=materialCost+laborCost;
//partioning the input and result area
System.out.println("----------------------");
//printing the size of floor and cost of the material
System.out.println("For a total floor size of "+size+" square feet the flooring cost is $"+materialCost);
//printing the time required and total cost of flooring
System.out.println("It will take "+totalTime+" hours to install the floor at cost of $"+totalCost);
}
  
}

Output:

You_Name Flooring Cost estimators

Please enter the length of the floor:25
Please enter the breadth of the floor:13
Please enter the cost per square feet of the flooring selected:12.5
----------------------
For a total floor size of 325 square feet the flooring cost is $4062.5
It will take 8.125 hours to install the floor at cost of $4352.96875