Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class HoneyWinterReserves_06 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double quantity = Double.parseDouble(scanner.nextLine());
- String name = scanner.nextLine();
- while (!name.equals("Winter has come"))
- {
- double total = 0;
- for (int i = 1; i <= 6; i++)
- {
- double collectedHoney = Double.parseDouble(scanner.nextLine());
- total += collectedHoney;
- }
- if (total < 0)
- {
- System.out.printf("%s was banished for gluttony%n", name);
- }
- quantity -= total;
- if (quantity <= 0)
- {
- break;
- }
- name = scanner.nextLine();
- }
- if (quantity > 0)
- {
- System.out.printf("Hard Winter! Honey needed %.2f.", quantity);
- }
- else
- {
- System.out.printf("Well done! Honey surplus %.2f.", Math.abs(quantity));
- }
- }
- }
Add Comment
Please, Sign In to add comment