Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double voucherValue = double.Parse(Console.ReadLine());
- string purchase = Console.ReadLine();
- int ticketsCount = 0;
- int purchaseCount = 0;
- bool noMoreMoney = false;
- while (purchase != "End")
- {
- double movieTicketPrice = 0;
- double otherPurchasePrice = 0;
- for (int i = 0; i < purchase.Length; i++)
- {
- char letter = purchase[i];
- if (purchase.Length > 8)
- {
- if (i == 0 || i == 1)
- {
- movieTicketPrice += letter;
- }
- else
- {
- ticketsCount++;
- break;
- }
- }
- else if (purchase.Length <= 8)
- {
- if ( i == 0)
- {
- otherPurchasePrice += letter;
- if (voucherValue < otherPurchasePrice)
- {
- noMoreMoney = true;
- break;
- }
- purchaseCount++;
- break;
- }
- }
- }
- if (noMoreMoney)
- {
- break;
- }
- voucherValue -= movieTicketPrice;
- voucherValue -= otherPurchasePrice;
- purchase = Console.ReadLine();
- }
- Console.WriteLine($"{ticketsCount}");
- Console.WriteLine($"{purchaseCount}");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement