Advertisement
Guest User

Untitled

a guest
Nov 20th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. Private int[] rateTable;
  2. Private int getChargingCost(int startHour, int chargeTime){
  3. int total = 0;
  4. int position = startHour;
  5. for(int i = 0; i<= chargeTime-1;i++){
  6. if(position == 24)
  7. position = 0;
  8. total += rateTable[position];
  9. position++;
  10. }
  11. return total;
  12. }
  13. Public int getChargeStartTime(int chargeTime){
  14. int total = 0;
  15. int answer;
  16. for (int x = 0;x<=rateTable.length-1;x++){
  17. int position = x;
  18. int maybeTotal = 0;
  19. for(int i = 0; i<= chargeTime-1;i++){
  20. if(position == 24)
  21. position = 0;
  22. maybeTotal += rateTable[position];
  23. if (i = chargeTime-1){
  24. if (maybeTotal > total){
  25. total = maybeTotal
  26. answer = x;
  27. }
  28. }
  29. position++;
  30. }
  31. return x;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement