/ Published in: Java
Determines most cost beneficial cutting method of fabric.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Created by: Seth Savage package quiltcalc; import java.util.*; import javax.swing.JOptionPane; import java.text.DecimalFormat; public class QuiltCalc { { // Variables double clothHeight = 42.0; double clothWidth = 0.0; double stripHeight = 42.0; double stripWidth = 0.0; double pieceHeight = 0.0; double pieceWidth = 0.0; double pieceAmt = 0.0; // Dependant Vaiables double piecesPerStripA = 0.0; double piecesPerStripB = 0.0; double stripAmtA = 0.0; double stripAmtB = 0.0; double stripAmtAForm; double stripAmtBForm; double clothWidthA = 0.0; double clothWidthB = 0.0; double WasteA; double WasteAHeight; double WasteBHeight; double WasteB; double ExtraA; double ExtraB; double pieceArea; double clothAreaA; double clothAreaB; double TotalPieceAreaA; double TotalPieceAreaB; double stripAmtALower; double stripAmtBLower; double WasteAreaA; double WasteAreaB; double TempCalc; double WasteAFinalH; double WasteBFinalH; double TotalWasteA; double TotalWasteB; // User Input // Assignments stripWidth = pieceWidth; // Calculations for Original Data pieceArea = (pieceHeight * pieceWidth); piecesPerStripA = (42/pieceHeight); stripAmtA = (pieceAmt/piecesPerStripA); clothWidthA = (stripAmtAForm * stripWidth); clothAreaA = (42 * clothWidthA); TotalPieceAreaA = (pieceAmt * pieceArea); WasteA = (clothAreaA - TotalPieceAreaA); TotalWasteA = WasteA; WasteAHeight = (42 - (piecesPerStripA * pieceHeight)); ExtraA = (stripWidth * WasteAHeight); WasteAreaA = (stripAmtALower * ExtraA); WasteA = WasteA - WasteAreaA; TempCalc = stripAmtAForm - stripAmtA; WasteAFinalH = (42 * TempCalc); // Calculation for Inverted Data--------------------------------------------- piecesPerStripB = (42/pieceWidth); stripAmtB = (pieceAmt/piecesPerStripB); clothWidthB = (stripAmtBForm * pieceHeight); clothAreaB = (42 * clothWidthB); TotalPieceAreaB = (pieceAmt * pieceArea); WasteB = (clothAreaB - TotalPieceAreaB); TotalWasteB = WasteB; "\nPiece Width: " +pieceWidth +"\nNumber of Pieces: " + pieceAmt +"\nNumber of Pieces per Strip: " +piecesPerStripA + "\nNumber of Strips: " +stripAmtAForm +"\nYardage (in inches): " + clothWidthA +"\n\n----------Using Initial Data-----------"+ "\nExtra on Last Strip: " +pieceWidth +" x "+WasteAFinalH + "\nExtra on Previous Strips: " +pieceWidth +" x " +WasteAHeight + "\nTotal Extra Area: " +TotalWasteA +"\n--------------------------------------------" +"\n\n\n----------Using Inverted Data-----------" + "\nTotal Extra Area: " +TotalWasteB+"\n-------------------------------------------------"); } }