Unit 3 Application - 2009 3B
int[] rateTable;
public int getChargingCost(int chargeTime){
int minimum_cost = 0;
int start_time = 0;
for (int hour=0; hour<24; hour++)
{
int total_rate = 0;
int curr_hour = hour;
for (int i=0; i < chargeTime; i++){
if( (curr_hour + i) > 23)
{
curr_hour = 0;
chargeTime -= i;
i = 0;
}
total_rate += rateTable[curr_hour + i];
}
if( (minimum_cost == 0) || (total_rate < minimum_cost) )
{
minimum_cost = total_rate;
start_time = hour;
}
}
return start_time;
}
public class Digits {
private ArrayList<Integer> digitList;
Integer maximum = digitList[0];
Integer counter = 0;
public boolean isStrictlyIncreasing() {
for (int i=1; i < len(digitList[]); i++){
if (maximum < digitList[i]){
maximum = digitList[i];
counter = counter +1;
}
else{
return false;
}
}
return true;
}
}
public boolean isBalanced(ArrayList<String> delimiters) {
int open = 0;
int close = 0;
for (String d: delimiters) {
if (d.equals(openDel)) {
open++;
} else if (d.equals(closeDel)) {
close++;
}
if (close > open) return false;
}
return open == close;
}