Question: The code is suppose to read all the inputs and spit out the output However it stopped after two Here's the code someone help #include
The code is suppose to read all the inputs and spit out the output

However it stopped after two

Here's the code someone help
#include #include using namespace std; const int MAX_TRANSACTIONS = 100; struct Transaction { char type; // 'd' for debit, 'c' for credit, 'b' for balance string date; double value; }; int daysInMonth(int month, int year) { if (month == 2) { if ((year % 400 == 0) || ((year % 100 != 0) && (year % 4 == 0))) return 29; // Leap year else return 28; } else if (month == 4 || month == 6 || month == 9 || month == 11) { return 30; } else { return 31; } } int main() { Transaction transactions[MAX_TRANSACTIONS]; int numTransactions = 0; // Read the initial balance double balance; cin >> transactions[0].date >> balance; transactions[0].type = 'b'; // 'b' for balance int startDay, startMonth, startYear; sscanf(transactions[0].date.c_str(), "%d/%d/%d", &startMonth, &startDay, &startYear); int currentDay = startDay; int currentMonth = startMonth; int currentYear = startYear; // Read transactions until 'q' or more than 30 days while (true) { // Handle overdraft before checking transaction order if (transactions[numTransactions].type == 'd' && balance > transactions[numTransactions + 1].type; if (transactions[numTransactions + 1].type == 'q') break; cin >> transactions[numTransactions + 1].date >> transactions[numTransactions + 1].value; int transactionDay, transactionMonth, transactionYear; sscanf(transactions[numTransactions + 1].date.c_str(), "%d/%d/%d", &transactionMonth, &transactionDay, &transactionYear); if (transactionYear = 30) { break; } } // Calculate and print average balance double averageBalance = balance / (numTransactions + 1); cout Example Input: 12/1/2023 500 d 12/11/2023 200 d 12/23/2023 100 c 12/28/2023 200 d 12/31/2023 250 Example Output: 30-day average balance (12/1/2023-12/30/2023): $360.00
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
