1 / 2100%
import java.util.Scanner;
public class Assignment02
{
//Main method
public static void main(String[] args)
{
//Initialize the Scanner
Scanner scan = new Scanner(System.in);
//Collect the inputs for the required fields (Length of road, Number
of Lanes, Depth of Asphalt, Days to complete project)
double lengthOfRoad = 0;
int numberOfLanes = 0;
int depthOfAsphalt = 0;
int daysToComplete = 0;
//Prompt for the required four inputs
//What is the length of road project in miles
System.out.println("Length of road projects (miles):");
lengthOfRoad = scan.nextDouble();
System.out.println(lengthOfRoad);
//What is the number of lanes required
System.out.println("Number of Lanes :");
numberOfLanes = scan.nextInt();
System.out.println(numberOfLanes);
//What is the depth of asphalt in inches
System.out.println("Depth of asphalt (inches) :");
depthOfAsphalt = scan.nextInt();
System.out.println(depthOfAsphalt);
//How many days are required to complete the project
System.out.println("Days to complete project :");
daysToComplete = scan.nextInt();
System.out.println(daysToComplete);
//Beginning of the outputs
System.out.println("=== Amount of materials needed ===");
//Compute the truckloads of asphalt needed
double trucksRequired = (((lengthOfRoad * 5280) * (numberOfLanes *
12) * (depthOfAsphalt / (double) 12)) * 150) / 10000;
// ((lengthOfRoad * 5280) * (numberOfLanes * 12) * (depthOfAsphalt /
12) * 150) / 10000;
//Calculate the number of stoplights needed (1 per mile and 1 extra
per lane)
int totalStopLights = ( (int) lengthOfRoad * (2 + (numberOfLanes)));
//Calculate the number of conduit pipes required, only comes in 24
ft lengths
/*-------------------------------------------------------------
// AUTHOR: Zachary Zeka
// FILENAME: Assignment02.java
// SPECIFICATION: This program takes user inputs and compiles them for a
construction company, the results are used for compiling material cost to help
quote on new jobs
// FOR: CSE 110 - Assignment #2
// TIME SPENT: 2 hours
//-----------------------------------------------------------*/
int conduitsRequired = (int) (lengthOfRoad * 5280) / 24;
//Calculate the number of crew members needed for the project and
create new int to round up the lengthOfRoad
int crewMembersNeeded = (int) Math.round((50 * lengthOfRoad *
numberOfLanes) / daysToComplete);
System.out.println("Truckloads of Asphalt :
"+Math.round(trucksRequired));
System.out.println("Stoplights : "+totalStopLights);
System.out.println("Conduit Pipes : "+conduitsRequired);
System.out.println("Crew members needed : "+crewMembersNeeded);
//Calculate the cost of the required materials
double costOfAsphalt = (Math.round(trucksRequired) * 5) * 200;
//Calculate the cost of cost of stoplights
double costOfStoplights = totalStopLights * 25000;
//Calculate the cost of conduit pipes
double costOfConduit = conduitsRequired * 500;
//Calculate the cost of labor
double laborCost = (crewMembersNeeded * daysToComplete * 8) * 25;
//Calculate the total cost of the project
double totalProjectCost = costOfAsphalt + costOfStoplights +
costOfConduit + laborCost;
//Print out all the cost values
System.out.println("=== Cost of Materials ============");
System.out.println("Cost of Asphalt :$"+costOfAsphalt);
System.out.println("Cost of Stoplights :$"+costOfStoplights);
System.out.println("Cost of Conduit pipes :$"+costOfConduit);
System.out.println("Cost of Labor :$"+laborCost);
System.out.println("=== Total Cost of Project ========");
System.out.println("Total cost of Project :$"+totalProjectCost);
}
}
Powered by TCPDF (www.tcpdf.org)
Students also viewed