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