Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Debugging {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int voucher = Integer.parseInt(scanner.nextLine());
- String purchase = scanner.nextLine();
- int countPurchases = 0;
- int countTicketsPurchased = 0;
- while (!"End".equals(purchase)) {
- int symbolToNumOne = (int) purchase.charAt(0);
- int symbolToNumTwo = (int) purchase.charAt(1);
- if (purchase.length() > 8) {
- if ((symbolToNumOne + symbolToNumTwo) <= voucher) {
- countTicketsPurchased++;
- voucher -= (symbolToNumOne + symbolToNumTwo);
- }else {
- break;
- }
- } else {
- if (symbolToNumOne <= voucher) {
- countPurchases++;
- voucher -= symbolToNumOne;
- }
- else {
- break;
- }
- }
- purchase = scanner.nextLine();
- }
- System.out.printf("%d\n%d", countTicketsPurchased, countPurchases);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement