View difference between Paste ID: aA6yhXtb and EjNBRHPb
SHOW: | | - or go back to the newest paste.
1
import java.util.Scanner;
2
3
public class Balance_05 {
4
    public static void main(String[] args) {
5
        Scanner scanner = new Scanner(System.in);
6
        String destination = scanner.nextLine(); //държава или "End"
7
        //стоп -> destination == "End"
8
        //продължаваме -> destination != "End"
9
        while(!destination.equals("End")) {
10
            //държава
11
            double excursionPrice = Double.parseDouble(scanner.nextLine());
12
            //събирам пари
13
            double availableMoney = 0;
14
            //стоп -> availableMoney >= excursionPrice
15
            //продължава -> availableMoney < excursionPrice
16
            while (availableMoney < excursionPrice) {
17
                double savedMoney = Double.parseDouble(scanner.nextLine());
18
                availableMoney += savedMoney;
19
            }
20
            //налични пари > пари за екскурзията
21
            System.out.printf("Going to %s!%n", destination);
22
            destination = scanner.nextLine();
23
        }
24
    }
25
}