Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ap222af;
- public class Step01_Lab11
- {
- public static void main(String[] args)
- {
- int boxes = 0;
- int totalBoxes = 0;
- int usedCandles = 0;
- for(int years = 1; years <= 100; ++years){
- usedCandles += years;
- if (usedCandles >24){
- boxes = usedCandles/24;
- totalBoxes += boxes;
- System.out.printf("År %d köp %d askar \n", years, boxes);
- usedCandles = (usedCandles - boxes * 24);
- }
- }
- System.out.printf("Det går åt %d askar och det blir %d ljus över", totalBoxes, 24-usedCandles);
- }
- }
Add Comment
Please, Sign In to add comment