Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- int vaucher = Integer.parseInt(scanner.nextLine());
- String purchase = null;
- int tickets = 0;
- int other = 0;
- while (vaucher > 0) {
- purchase = scanner.nextLine();
- if (purchase.equals("End")) {
- break;
- }
- if (purchase.length() > 8) {
- vaucher -= (int)purchase.charAt(0) + (int)purchase.charAt(1);
- if (vaucher > 0) {
- tickets++;
- }
- } else {
- vaucher -= (int)purchase.charAt(0);
- if (vaucher > 0) {
- other++;
- }
- }
- }
- System.out.println(tickets);
- System.out.println(other);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement