Unit 03 Tue - Boolean Expressions and if Statements
Homework
public int getChargeStartTime (int chargeTime) {
int startHour = 0;
int lowPrice = 500_000;
for (int x = 0; x < 23; x++) {
if (lowPrice > getChargingCost(x, chargeTime)) {
lowPrice = getChargingCost(x, chargeTime);
startHour = x;
}
}
return startHour;
}
public boolean isStrictlyIncreasing () {
boolean increasing = true;
for (int i = 1; i < digitListSize(); i++) {
if (digitList.get(i-1) >= digitList.get(i)) {
increasing = false;
}
}
return increasing;
}
public boolean isBalanced(ArrayList<String> delimiters) {
int numOpen = 0, numClosed = 0;
for(String d : delimiters) {
if(d.equals(openDel))
numOpen++;
if(d.equals(closeDel))
numClosed++;
if(numClosed > numOpen)
return false;
}
return numOpen == numClosed;
}