Advertisement
psi_mmobile

Untitled

May 26th, 2022
994
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         java.util.Scanner scanner = new java.util.Scanner(System.in);
  4.         int vaucher = Integer.parseInt(scanner.nextLine());
  5.         String purchase = null;
  6.         int tickets = 0;
  7.         int other = 0;
  8.         while (vaucher > 0) {
  9.             purchase = scanner.nextLine();
  10.             if (purchase.equals("End")) {
  11.                 break;
  12.             }
  13.             if (purchase.length() > 8) {
  14.                 vaucher -= (int)purchase.charAt(0) + (int)purchase.charAt(1);
  15.                 if (vaucher > 0) {
  16.                     tickets++;
  17.                 }
  18.             } else {
  19.                 vaucher -= (int)purchase.charAt(0);
  20.                 if (vaucher > 0) {
  21.                     other++;
  22.                 }
  23.             }
  24.         }
  25.         System.out.println(tickets);
  26.         System.out.println(other);
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement