A_Marinov

Problem_06

Jun 7th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class HoneyWinterReserve_06 {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         double honeyForWinter = Double.parseDouble(scan.nextLine());
  8.  
  9.         double total = 0;
  10.  
  11.         String input = scan.nextLine();
  12.         while (!input.equals("Winter has come")) {
  13.             for (int i = 1; i <= 6; i++) {
  14.                 double honeyBring = Double.parseDouble(scan.nextLine());
  15.                 total += honeyBring;
  16.             }
  17.             if (total < 0) {
  18.                 System.out.printf("%s was banished for gluttony%n", input);
  19.             }
  20.             if (total >= honeyForWinter) {
  21.                 System.out.printf("Well done! Honey surplus %.2f.", total - honeyForWinter);
  22.                 break;
  23.             }
  24.             input = scan.nextLine();
  25.         }
  26.         if (total < honeyForWinter) {
  27.             System.out.printf("Hard Winter! Honey needed %.2f.", honeyForWinter - total);
  28.         }
  29.  
  30.  
  31.     }
  32. }
Add Comment
Please, Sign In to add comment