Return to Snippet

Revision: 72291
at June 28, 2017 08:34 by sethsavage


Updated Code
// Created by: Seth Savage

package quiltcalc;
import java.util.*;
import javax.swing.JOptionPane;
import java.text.DecimalFormat;


public class QuiltCalc 
{

    public static void main(String[] args) 
    {
    // 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;
    String HeightString = "";
    String WidthString = "";
    String AmtString = "";
    DecimalFormat format = new DecimalFormat("#.##");
    
    // 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
    HeightString = JOptionPane.showInputDialog("Height of Pieces:");
    pieceHeight = Double.parseDouble(HeightString);
    
    WidthString = JOptionPane.showInputDialog("Width of Pieces:");
    pieceWidth = Double.parseDouble(WidthString);
    
    AmtString = JOptionPane.showInputDialog("Number of Pieces:");
    pieceAmt = Double.parseDouble(AmtString);
    
    // Assignments
    stripWidth = pieceWidth;
    
    // Calculations for Original Data
    pieceArea = (pieceHeight * pieceWidth);
    piecesPerStripA = (42/pieceHeight);
    piecesPerStripA = (double) Math.floor(piecesPerStripA);
    stripAmtA = (pieceAmt/piecesPerStripA);
    stripAmtAForm = (double) Math.ceil(stripAmtA);
    clothWidthA = (stripAmtAForm * stripWidth);
    clothAreaA = (42 * clothWidthA);
    TotalPieceAreaA = (pieceAmt * pieceArea);
    
    WasteA = (clothAreaA - TotalPieceAreaA);
    TotalWasteA = WasteA;
    
    WasteAHeight = (42 - (piecesPerStripA * pieceHeight));
    ExtraA = (stripWidth * WasteAHeight);
    stripAmtALower = (double) Math.floor(stripAmtA);
    WasteAreaA = (stripAmtALower * ExtraA);
    
    WasteA = WasteA - WasteAreaA;
    TempCalc = stripAmtAForm - stripAmtA;
    WasteAFinalH = (42 * TempCalc);
    WasteAFinalH = Math.round(WasteAFinalH * 100.0)/100.0;
    
    
    
    // Calculation for Inverted Data---------------------------------------------
    piecesPerStripB = (42/pieceWidth);
    piecesPerStripB = (double) Math.floor(piecesPerStripB);
    stripAmtB = (pieceAmt/piecesPerStripB);
    stripAmtBForm = (double) Math.ceil(stripAmtB);
    clothWidthB = (stripAmtBForm * pieceHeight);
    clothAreaB = (42 * clothWidthB);
    TotalPieceAreaB = (pieceAmt * pieceArea);
    WasteB = (clothAreaB - TotalPieceAreaB);
    TotalWasteB = WasteB;
    
    
    
   
    
    JOptionPane.showMessageDialog(null,"Piece Height: " +pieceHeight +
            "\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-------------------------------------------------");
      
    }
    
}

Revision: 72290
at June 28, 2017 08:32 by sethsavage


Initial Code
// Created by: Seth Savage

package quiltcalc;
import java.util.*;
import javax.swing.JOptionPane;
import java.text.DecimalFormat;


public class QuiltCalc 
{

    
    
    
   
    public static void main(String[] args) 
    {
    // 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;
    String HeightString = "";
    String WidthString = "";
    String AmtString = "";
    DecimalFormat format = new DecimalFormat("#.##");
    
    // 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
    HeightString = JOptionPane.showInputDialog("Height of Pieces:");
    pieceHeight = Double.parseDouble(HeightString);
    
    WidthString = JOptionPane.showInputDialog("Width of Pieces:");
    pieceWidth = Double.parseDouble(WidthString);
    
    AmtString = JOptionPane.showInputDialog("Number of Pieces:");
    pieceAmt = Double.parseDouble(AmtString);
    
    // Assignments
    stripWidth = pieceWidth;
    
    // Calculations for Original Data
    pieceArea = (pieceHeight * pieceWidth);
    piecesPerStripA = (42/pieceHeight);
    piecesPerStripA = (double) Math.floor(piecesPerStripA);
    stripAmtA = (pieceAmt/piecesPerStripA);
    stripAmtAForm = (double) Math.ceil(stripAmtA);
    clothWidthA = (stripAmtAForm * stripWidth);
    clothAreaA = (42 * clothWidthA);
    TotalPieceAreaA = (pieceAmt * pieceArea);
    
    WasteA = (clothAreaA - TotalPieceAreaA);
    TotalWasteA = WasteA;
    
    WasteAHeight = (42 - (piecesPerStripA * pieceHeight));
    ExtraA = (stripWidth * WasteAHeight);
    stripAmtALower = (double) Math.floor(stripAmtA);
    WasteAreaA = (stripAmtALower * ExtraA);
    
    WasteA = WasteA - WasteAreaA;
    TempCalc = stripAmtAForm - stripAmtA;
    WasteAFinalH = (42 * TempCalc);
    WasteAFinalH = Math.round(WasteAFinalH * 100.0)/100.0;
    
    
    
    // Calculation for Inverted Data---------------------------------------------
    piecesPerStripB = (42/pieceWidth);
    piecesPerStripB = (double) Math.floor(piecesPerStripB);
    stripAmtB = (pieceAmt/piecesPerStripB);
    stripAmtBForm = (double) Math.ceil(stripAmtB);
    clothWidthB = (stripAmtBForm * pieceHeight);
    clothAreaB = (42 * clothWidthB);
    TotalPieceAreaB = (pieceAmt * pieceArea);
    WasteB = (clothAreaB - TotalPieceAreaB);
    TotalWasteB = WasteB;
    
    
    
   
    
    JOptionPane.showMessageDialog(null,"Piece Height: " +pieceHeight +
            "\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-------------------------------------------------");
    
    
    
       
    
        
        
        
    }
    
}

Initial URL


Initial Description
Determines most cost beneficial cutting method of fabric.

Initial Title
Quilt Calculator

Initial Tags


Initial Language
Java