Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class MelonsWatermelons {
- public enum Days {
- MONDAY (1, 0),
- TUESDAY (0, 2),
- WEDNESDAY (1, 1),
- THURSDAY (2, 0),
- FRIDAY (2, 2),
- SATURDAY (1, 2),
- SUNDAY (0, 0);
- private final int waterMelons;
- private final int melons;
- Days(int waterMelons, int melons) {
- this.waterMelons = waterMelons;
- this.melons = melons;
- }
- }
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int startDay = input.nextInt();
- int howManyDays = input.nextInt();
- int totalWaterMelons = 0;
- int totalMelons = 0;
- while (howManyDays > 0) {
- if (startDay > 7) {
- startDay = 1;
- }
- totalWaterMelons += Days.values()[startDay-1].waterMelons;
- totalMelons += Days.values()[startDay-1].melons;
- startDay++;
- howManyDays--;
- }
- if (totalWaterMelons > totalMelons) {
- System.out.printf("%d more watermelons", totalWaterMelons - totalMelons);
- }
- else if (totalMelons > totalWaterMelons) {
- System.out.printf("%d more melons", totalMelons - totalWaterMelons);
- }
- else {
- System.out.printf("Equal amount: %d", totalWaterMelons);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement