Paul is building a workshop and has already figured out what materials you need.
ID: 3666071 • Letter: P
Question
Paul is building a workshop and has already figured out what materials you need. The following table shows the cost at one of the local lumberyards for each item as well as the number of item Paul needs. Write a program that creates a report that lists each item, the quantity of each item, the cost per item, and the total cost for that item. The report should also include the total cost of all materials. Because Paul wants to determine which lumberyard will give him the best deal, he will need to be able to specify the cost of each item.
Sample Data
Description Unit Cost Quantity Needed Joists 75.99 25 2 x 6 8.90 100 2 x 4 4.95 25 4 x 4 12.95 20 4 x 8 sheet plywood 22.00 100Explanation / Answer
import java.util.*; import java.lang.*; import java.io.*; class WorkShop{ public static void main(String[] args) { // initiating three arrays such as lumberyards,unit cost and quantity needed String[] lumberyards = {" Joists", " 2 x 6", " 2 x 4"," 4 x 4"," 4 x 8 sheet plywood"}; double[] unitcost = {75.99,8.90,4.95,12.95,22.00}; int[] quantityneeded = {25,100,25,20,100}; double totalcost=0; System.out.println(" lists each item quantity of each item cost per item the total cost for that item "); // Print the report for (int i = 0; i < 5; i++) { System.out.println(lumberyards[i]+ " " + quantityneeded[i]+ " "+unitcost[i]+ " " + quantityneeded[i]* unitcost[i]); totalcost=totalcost+ quantityneeded[i]* unitcost[i]; } System.out.println("Total cost is " + totalcost); } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.