Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Lab05 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String destination = scanner.nextLine();
  7.  
  8.  
  9.         while (!"End".equals(destination)) {
  10.             int budget = Integer.parseInt(scanner.nextLine());
  11.             int sumOfSavings = 0;
  12.             while (budget >= sumOfSavings) {
  13.                 int savings = Integer.parseInt(scanner.nextLine());
  14.                 sumOfSavings += savings;
  15.             }
  16.             System.out.printf("Going to %s!%n", destination);
  17.             destination = scanner.nextLine();
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement