Question: Ive been trying to learn the problem for awhile here's my code #include #include using namespace std; const int MAX_TRANSACTIONS = 100; struct Transaction {
Ive been trying to learn the problem for awhile here's my code
#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 when ran with the input it outputs


the actual output is suppose to be

Can someone please help I have been working on this all day. The code is suppose to stop after 30 days and then take the average but rightnow its not getting passed the first set of days.
12/1/2023 500 d 12/11/2023 200 d 12/23/2023 100 c 12/28/2023 200 d 12/31/2023 250
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
