Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package VlojeniCikli;
- import java.util.Scanner;
- public class Zad6 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String destination=scanner.nextLine();
- int budgetNeeded=Integer.parseInt(scanner.nextLine());
- int sum=0;
- while (!destination.equals("End")){
- int money=Integer.parseInt(scanner.nextLine());
- sum+=money;
- if (sum==budgetNeeded||sum>budgetNeeded){
- System.out.printf("Going to %s!\n",destination);
- sum=0;
- destination=scanner.nextLine();
- if ("End".equals(destination)){
- break;
- }
- budgetNeeded=Integer.parseInt(scanner.nextLine());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement