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