Question

write a program using MATLAB ‘A’ contains all account numbers and balances. ‘B’ contains debits/credits for...

write a program using MATLAB

‘A’ contains all account numbers and balances. ‘B’ contains debits/credits for each account.
Write a program that updates ‘A’ based on information in ‘B’. Also create a separate matrix ‘C’ that contains only the new accounts not in A.

A= Acct# Balance

[5 1000
2 5000

82 68
7 10]

B= Acct# Credit/Debit

[5 -100

8 2000

12 3000

14 1
7 -20]

Output

A= Acct# Balance

[5 900

2 5000

8 2002

6 8
7 -10

12 3000

14 1]

C = Acct# Credit/Debit

[12 3000

14 1]

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The above problem can be solved in the following steps-

STEP 1- First we will define and intialize the two matrices A and B. A will have the account no and balance as two columns. And matrix B will have the account no and action(credit/debit) as two columns.Use the data given in question to create two matrix A and B

STEP 2- Then we will iterate through matrix A and in inner loop iterate through matrix B.
In the inner loop, check if account no in matrix A matches any account no in matrix B

If yes, then perform credit/debit action on the account balance of the matched account no.

And then in the matrix B, mark this account no as 0, because this account no. exists in A. This will help us in creating matrix C where we will have new account nos which are not present in A right now.

STEP 3- Then we will create matrix C. Iterate through the matrix B. And check which all account nos are not equal to 0.(this is because the account nos which were present in A are marked as 0).

If non zero account no is there, concat the row contents to matrix C. In this way matrix C is constructed.

STEP 4- Now matrix A to be displayed as output has all the account no along with balance(both the old and new account nos). So concat matrix A and C and form a new matrix A and display that matrix.

Also, display the matrix C at the end.

MATLAB CODE-

%create matrix A and store all the given information
% A = Acct# Balance
A= [5 1000
2 5000
8 2
6 8
7 10];
%create marix B and store all the given information
% B = Acct# Credit/Debit
B= [5 -100
8 2000
12 3000
14 1
7 -20];

%iterate through the matrix A
for i=1:length(A)
%and then inner loop iterates through matrix B
for j=1:length(B)
%if account number in A matches account number in B
if(A(i,1) == B(j,1))
%change the account balance in A as instructed in B(2nd column)
A(i,2) = A(i,2) + B(j,2);
%and make that account number in B as 0, that means this
%account number was present in A, so it is changed to 0
%this will help in creating matrix C as shown below
B(j,1) = 0;
end
end
end
%now we will create matrix C such that it contains new account nos in B not
%present in A
C = [];
%iterate through the matrix B
for i=1:length(B)
%if account number in matrix B is not 0, means it was not present in A
%as shown above, so add this row to matrix C
if(B(i,1) ~= 0)
C = cat(1,C,B(i,:)); %concat this row in B to matrix C
end
end
%now matrix will have all account nos and balance from matrix A and B both
A = cat(1,A,C); %so concat A and C matrix
disp('A = Acct# Balance ');
disp(A); %display the matrix A
%and then display the matrix C
disp('C = Acct# Credit/Debit');
disp(C);

IMAGE OF CODE-

create matrix A and store all the given information % A = Acct# Balance A= [5 1000 2 5000 8 2 6 8 7 10]; create marix B and s

32 33 - 34 35 - 36 m 38 - Enow we will create matrix C such that it contains new account nos in B not present in A C = []; li

OUTPUT-

Acct# Balance 900 5000 2002 -10 3000 C = Acct Credit/Debit 3000 12

If this answer helps, please give an up vote and feel free to comment for any query.

Add a comment
Know the answer?
Add Answer to:
write a program using MATLAB ‘A’ contains all account numbers and balances. ‘B’ contains debits/credits for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 7. An account will have a credit balance if the A)debits exceed the credits. B)credits exceed...

    7. An account will have a credit balance if the A)debits exceed the credits. B)credits exceed the debits. C)first transaction entered was a credit. D)last transaction entered was a credit. 10. Which of the following is incorrect as to category, normal balance, financial statement, to increase, to decrease A)Cash - asset, debit, balance sheet, credit, debit B)Accounts Payable - liabilities, debit, balance sheet, credit, debit C)Common Stock - shareholders equity, debit, balance sheet, credit, debit D)Service Revenue - revenue, credit,...

  • Please explain why? Thanks 6. In general, debits refer to increases in account balances, and credits...

    Please explain why? Thanks 6. In general, debits refer to increases in account balances, and credits refer to decreases. False 7. The first step in the accounting cycle is the journalizing of transactions and selected other events. False 10. If a company fails to post one of its journal entries to its general ledger, the trial balance will not show an equal amount of debit and credit balance accounts. False 13. The book value of any depreciable asset is the...

  • 8. The total debits in the Account Payable T-account are $1,100 and the total credits are...

    8. The total debits in the Account Payable T-account are $1,100 and the total credits are $2,000. (be sure to indicate if it is a Calculate the balance in the Account Payable account credit or debit balance) 9. XYZ Services received $300 from a customer on 3/1/20 for services to be performed in the future. What effect (if any) does this transaction have on the assets, liabilities, and equity of XYZ Services (do not provide the journal entry in your...

  • On January 1, 2018, the general ledger of Big Blast Fireworks includes the following account balances:   ...

    On January 1, 2018, the general ledger of Big Blast Fireworks includes the following account balances:    Accounts Debit Credit Cash $ 24,700 Accounts Receivable 43,500 Inventory 44,000 Land 82,600 Allowance for Uncollectible Accounts 3,100 Accounts Payable 28,200 Notes Payable (9%, due in 3 years) 44,000 Common Stock 70,000 Retained Earnings 49,500 Totals $ 194,800 $ 194,800 The $44,000 beginning balance of inventory consists of 440 units, each costing $100. During January 2018, Big Blast Fireworks had the following inventory transactions:   ...

  • jeneral ledger of Zips Storage at January 1, 2021, includes the following account balances: Credits Debits...

    jeneral ledger of Zips Storage at January 1, 2021, includes the following account balances: Credits Debits $ 25,400 16,200 13,600 156,000 Accounts Cash Accounts Receivable Prepaid Insurance Land Accounts Payable Deferred Revenue Common Stock Retained Earnings Totals $ 7.500 6,600 151,000 46,100 $211,200 $211,200 The following is a summary of the transactions for the year: 1. January 9 Provide storage services for cash, 5142,100, and on account, $56,200. 2. February 12 Collect on accounts receivable, $52,300. 3. April 25 Receive...

  • B. (Record debits first, then credits. Select the explanation on the last line of the journal...

    B. (Record debits first, then credits. Select the explanation on the last line of the journal entry table.) * More Info Debit a. Depreciation, $600. b. Prepaid rent expires. $900. c. Interest expense accrued, $200. Employee salaries owed for Monday through Thursday of a five-day workweek, weekly payroll, $13,000. e. Unearned revenue earned, $800. Office supplies used. $250. t when rent is paid in Debit Print Done n continue to the next a U I JUL Te luwilig udla July...

  • On January 1, 2021, the general ledger of Freedom Fireworks includes the following account balances: Debit 12,400 Credi...

    On January 1, 2021, the general ledger of Freedom Fireworks includes the following account balances: Debit 12,400 Credit Accounts Cash Accounts Receivable 36,400 Inventory 153,200 Land 79,300 Buildings 132,000 $ 3,000 10,800 Allowance for Uncollectible Accounts Accumulated Depreciation Accounts Payable Common Stock 30,900 212,000 Retained Earnings 156,600 $413,300 $413,300 Totals During January 2021, the following transactions occur: Borrow $112,000 from Captive Credit Corporation. The installment note bears interest at matures in 5 years. Payments of $2,165 are required at the...

  • 8. Mary Neylon has trouble keeping her debits and credits equal. During a recent month, Mary...

    8. Mary Neylon has trouble keeping her debits and credits equal. During a recent month, Mary made the following accounting errors: 12(Click the icon to view the accounting errors.) Print Read the requirements 13. Requirement 1. For each of these errors, state whether total debits equal total credits on the trial balance. For each error determine whether total debils are "Greater than">), "Equal to" (=), or "Less than" (<) total credits. a. Total debits Total credits b. Total debits (2)...

  • The general ledger of Zips Storage at January 1, 2021, includes the following account balances: Credits...

    The general ledger of Zips Storage at January 1, 2021, includes the following account balances: Credits Accounts Cash Accounts Receivable Prepaid Insurance Land Accounts Payable Deferred Revenue Common Stock Retained Earnings Totals Debits $ 25,400 16,200 13,600 156,000 $ 7,500 6,600 151,000 46, 100 $211,200 $211,200 The following is a summary of the transactions for the year: 1. January 9 Provide storage services for cash, $142,100, and on account, $56,200. 2. February 12 Collect on accounts receivable, $52,300. 3. April...

  • (4) all debits to Accounts Payable reflect cash payments for inventory. (5) Other Expenses are all...

    (4) all debits to Accounts Payable reflect cash payments for inventory. (5) Other Expenses are all cash e Income Taxes Payable reflects the accrual and cash payment of taxes. GOLDEN CORPORATION Comparative Balance Sheets December 31 Current Year Prior 164,000 83,000 601,000 848,000 335,000 (158,000) $1,025,000 $ 107,000 71,000 526,000 704,000 299,000 (104,000) $ 899,000 Assets Cash Accounts receivable Inventory Total current assets Equipment Accum. depreciation Equipment Total assets Liabilities and Equity Accounts payable Income taxes payable Total current liabilities...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT