Question

CSE110 Principles of Programming Assignment 02.10 pts Assignment 02:100 pts CSE110 Principles of Programming Test #2 Given InJAVA language


CE11 Principles of Programming Test2 Gynas Length of road project (niles) : 3 Number of lanes Depth of asphalt (inches) : 18

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

import java.lang.Math;
import java.util.Scanner;

public class Road {
   public static void main(String[] args) {
       // Scanner object to get user input
       Scanner sc = new Scanner(System.in);

       // variables to store user input
       double length, depth; // length of road, depth of asphalt
       int lanes, days; // number of lanes, number of days

       // getting user input
       System.out.print("Length of road project (miles): ");
       length = Double.parseDouble(sc.nextLine()); // getting input as a string then parsing int
       System.out.print("Number of lanes : ");
       lanes = Integer.parseInt(sc.nextLine());
       System.out.print("Depth of asphalt (inches) : ");
       depth = Double.parseDouble(sc.nextLine());
       System.out.print("Days to complete project : ");
       days = Integer.parseInt(sc.nextLine());

       // calculating materials required
       double asphalt = ((length*5280)*lanes*depth)*150/2000;
       int truckLoads = (int)Math.round(asphalt/5);
       int intersections = (int)length;
       int conduitPipes = (int)(length*5280)/24; // convert the miles to feet and divide by 24
       int stoplights = (lanes + 2)*intersections;
       int crewMembers = (int)Math.round((50*length*lanes)/days);
       // calculating cost of materials
       double costOfAsphalt = truckLoads*1000;
       double costOfStoplights = stoplights*25000;
       double costOfPipes = conduitPipes*500;
       double costOfLabor = crewMembers*days*8*25;
       double totalCost = costOfAsphalt + costOfStoplights + costOfPipes + costOfLabor;

       // printing all the outputs
       System.out.println();
       System.out.println("=== Amount of materials needed ===");
       System.out.println("Truckloads of Asphalt : "+truckLoads);
       System.out.println("Stoplights : "+stoplights);
       System.out.println("Conduit pipes : "+conduitPipes);
       System.out.println("Crew members needed : "+crewMembers);
       System.out.println("=== Cost of Materials ============");
       System.out.printf("Cost of Asphalt : $%.2f\n", costOfAsphalt);
       System.out.printf("Cost of Stoplights : $%.2f\n", costOfStoplights);
       System.out.printf("Cost of Conduit pipes : $%.2f\n", costOfPipes);
       System.out.printf("Cost of Labor : $%.2f\n", costOfLabor);
       System.out.println("=== Total Cost of Project ========");
       System.out.printf("Total cost of project : $%.2f\n", totalCost);
   }
}

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
JAVA language CSE110 Principles of Programming Assignment 02.10 pts Assignment 02:100 pts CSE110 Principles of Programming...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Your company is planning to bid a contract to lay 60,000 square yards of asphalt pavement...

    Your company is planning to bid a contract to lay 60,000 square yards of asphalt pavement to improve the Carolinas airport runway. You have been asked to estimate the duration and direct equipment cost of the project. The contract specifications require that the pavement be 3 inches thick after compaction. The mix design is such that you estimate the asphalt to weigh 3,100 pounds per cubic yard when loose and 3,900 pounds per cubic yard after it has been compacted....

  • Needs Help with Java programming language For this assignment, you need to write a simulation program...

    Needs Help with Java programming language For this assignment, you need to write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: • delete the addfirst, addlast, and add(index) methods and...

  • Analyze the case the answer the questions: introduction of the case assess the financial reporting landscape...

    Analyze the case the answer the questions: introduction of the case assess the financial reporting landscape considering the user needs, constraints, and business environment, identify the issues, analyze the issues (qualitatively and quantitatively), and provide a recommendation and conclusion. Original content only no copy-paste, please INTRODUCTION Jaden McCoy operated a dairy goat farm in Soddy-Daisy, Tennessee, and was considering expanding the rental of his goats for land clearing. In early 2011, McCoy successfully bid on a job to clear a...

  • INTRODUCTION Jaden McCoy operated a dairy goat farm in Soddy-Daisy, Tennessee, and was considering expanding the...

    INTRODUCTION Jaden McCoy operated a dairy goat farm in Soddy-Daisy, Tennessee, and was considering expanding the rental of his goats for land clearing. In early 2011, McCoy successfully bid on a job to clear a section of property at a nearby resort. McCoy's goats performed as expected and he eamed a small profit in the process. The resort manager was quite happy because the difficult-to-reach areas of the property were cleared on time and on budget at a cost well...

  • How can we assess whether a project is a success or a failure? This case presents...

    How can we assess whether a project is a success or a failure? This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...

  • I have this case study to solve. i want to ask which type of case study...

    I have this case study to solve. i want to ask which type of case study in this like problem, evaluation or decision? if its decision then what are the criterias and all? Stardust Petroleum Sendirian Berhad: how to inculcate the pro-active safety culture? Farzana Quoquab, Nomahaza Mahadi, Taram Satiraksa Wan Abdullah and Jihad Mohammad Coming together is a beginning; keeping together is progress; working together is success. - Henry Ford The beginning Stardust was established in 2013 as a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT