Skip to content

Commit

Permalink
Divide by zero error fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
pbellchambers committed Mar 22, 2012
1 parent c849538 commit d153836
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ public static void setLedgerEquipmentCostData(){
}
}

//TODO: Fix divide by zero error

public static void setBrewTotalCostData(){
BigDecimal total = new BigDecimal("0");
for (int i = 0; i < (LedgerEquipmentCostTable.getRowCount()); i++ ) {
Expand Down
14 changes: 12 additions & 2 deletions winebrewdb/src/com/pori/WineBrewDB/SQLite/DBEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -1472,14 +1472,19 @@ public static BigDecimal getTotalNumberBrews() throws Exception {

ResultSet rs = pre.executeQuery();
int NumberBrews = 0;
BigDecimal DecimalNumberBrews = new BigDecimal("0");

while(rs.next()){
//Add one to the current highest
NumberBrews = rs.getInt(1);
}

BigDecimal DecimalNumberBrews = new BigDecimal(NumberBrews);

if(NumberBrews == 0){
DecimalNumberBrews = new BigDecimal("0.00000001");
}else{
DecimalNumberBrews = new BigDecimal(NumberBrews);
}

/*Close the connection after use (MUST)*/
if(conn!=null)
Expand All @@ -1501,14 +1506,19 @@ public static BigDecimal getTotalNumberBottles() throws Exception {

ResultSet rs = pre.executeQuery();
int NumberBottles = 0;
BigDecimal DecimalNumberBottles = new BigDecimal("0");

while(rs.next()){
//Add one to the current highest
NumberBottles = rs.getInt(1);
}

BigDecimal DecimalNumberBottles = new BigDecimal(NumberBottles);

if(NumberBottles == 0){
DecimalNumberBottles = new BigDecimal("0.00000001");
}else{
DecimalNumberBottles = new BigDecimal(NumberBottles);
}

/*Close the connection after use (MUST)*/
if(conn!=null)
Expand Down

0 comments on commit d153836

Please sign in to comment.