Question

In: Computer Science

4   Write an algorithm to settle the following questions: Accept a starting balance (For example :A...

4   Write an algorithm to settle the following questions:

Accept a starting balance (For example :A bank account starts out with $10,000) Accept an Interest rate (For example: 6 percent per year is 0.005 percent per month).

Accept an amount to withdraw every month (For example: Every month, $500 is withdrawn to meet college expenses.)

After how many years is the account depleted? (You are to loop and find out how many months this will take) (For example: Suppose the values ($10,000, 6 percent, $500) were user selectable, then how many months would it take to deplete the account?)

Are there values for which the algorithm you developed would not terminate? (For example if the interest calculated for each month exceeds the withdrawal every month). If so, change the algorithm to make sure it always terminates.

Don't write the program, just write it in pseudo English.

Solutions

Expert Solution

The solution of the given scenario with includes the following actions in the pseudocode:

  1. Creation of account for student
  2. Calculating total months for which the student can withdraw the amount
  3. Withdraw of the monthly fixed amount after validating the count of months for which the student can withdraw the amount

The complete Pseudocode is given as below:

-----------------------------------------------------------------------------------------------------------

START:

CreateAccount:

            Enter student details;

            Deposit more than $10,000 as total deposit;

Enter monthlywithdrawalamount which the student need to withdraw every month to meet college expenses;

IF(monthlywithdrawalamount > total deposit)

            Then: Ask the student to enter new monthly limit as it exceeds the deposited amount

ENDIF;

Totalbalance = DepositAmount+ Monthly Interest; // Interest will be added every month

WithdrawalTotalMonths = (Totalbalance)/ monthlywithdrawalamount

The student can withdraw the money for WithdrawalMonths number of months

WidthdrawAmount:

            Set withdrawTotalMonths == 0;//counts the number of months for which the amount is withdrawn

            While(MonthstoDeplete >= withdrawTotalMonths )

                        Withdraw the money for the student

                        Set withdrawMonths   = withdrawMonths   + 1

            endwhile

IF( totalAmount > 0 and MonthstoDeplete < withdrawTotalMonths)

                        Withdraw the left amount and set the account balance to 0;

         ENDIF;

END;

-------------------------------------------------------------------------------------------------------------------------

Explanation of pseudocode for a better understanding:

CreateAccount code will create a new account of the student. The student will need to add the asked details and make a deposit of $10,000 or more. The monthly withdrawal will be asked from the student in below code:

CreateAccount:

            Enter student details;

            Deposit more than $10,000 as total deposit;

Enter monthlywithdrawalamount which the student need to withdraw every month to meet college expenses;

Once the monthly withdrawal amount is entered by the student, the same will be validated against the total amount to make sure it is less than the total amount and student will be asked to enter a new amount in below code:

IF(monthlywithdrawalamount > total deposit)

            Then: Ask the student to enter new monthly limit as it exceeds the deposited amount

ENDIF;

The below calculations will be made to calculate the total amount left in the account after addition of monthly interest . The left amount in the account will calculate the number of months for which the student can withdraw the money:

Totalbalance = DepositAmount+ Monthly Interest; //interest will be added monthly

WithdrawalTotalMonths: (Totalbalance)/ monthlywithdrawalamount

The student can withdraw the money for WithdrawalMonths number of months

The below code will maintain a variable for counting the number of months for which the student has withdrawn the money and before every withdrawal check, the remaining month to withdraw the money will be compared. If the student has months for which the money can be withdrawn, the amount will be deducted .

            Set withdrawMonths == 0;//counts the number of months for which the amount is withdrawn

            While(withdrawMonths >= withdrawTotalMonths and Totalbalance >0)

                        Withdraw the money for the student

                        Set withdrawMonths   = withdrawMonths   + 1

            Endwhile

If the amount left in the account if less than the monthly limit and the withdrawal months has been completed, below code will withdraw the remaining amount and delete the account:

IF( totalAmount > 0 and MonthstoDeplete < withdrawTotalMonths)

                        Withdraw the left amount and set the account balance to 0;

            ENDIF;


Related Solutions

using Java, Implement the following algorithm: - Accept 5 different memory partitions and 4 different processes...
using Java, Implement the following algorithm: - Accept 5 different memory partitions and 4 different processes from user and show how best fit algorithm allocates them.
Answer the following questions(5pt) a)   Write an algorithm that finds the largest item in an array...
Answer the following questions(5pt) a)   Write an algorithm that finds the largest item in an array of n items by using divide-and-conquer algorithm design pattern. b)   Analyze the worst-case time complexity of your algorithm in (a), and show the results using asymptotic notation (ϴ)
write an algorithm function called balance() in javascript that takes in a string and returns a...
write an algorithm function called balance() in javascript that takes in a string and returns a strinf with balanced parantheses only. the string should be able to contain only parantheses, numbers, and letters. include comments of each portion of your code balance(“()()”) should return “()()” balance(“())”) should return “()” balance(“a(b)c”) should return “a(b)c” balance(“a(b)c())”) should return “a(b)c()”
Consider the operating cycle to answer the following questions. Operating Cycle cash-- settle payables -- Account...
Consider the operating cycle to answer the following questions. Operating Cycle cash-- settle payables -- Account Payable-- purchases -- Buy with payables-- inventories -- sales-- accounts receivable -- returned to cash -- (Again the cycle repeat) --- Cash Why might a company want to reduce its cash conversion cycle? (Hint: Consider the financial statement implications of reducing the cash conversion cycle.) How might a company reduce its cash conversion cycle? Examine and discuss the potential impacts on customers and suppliers...
1. Sort the given keys using Counting sort algorithm. Also write the algorithm.          4, 1,...
1. Sort the given keys using Counting sort algorithm. Also write the algorithm.          4, 1, 0, 2, 1, 5, 0, 4                                                                     No code or programs, please. Manually solve the problem, please. Thanks
I have to write an initial algorithm and a refined algorithm for the following problem: Display...
I have to write an initial algorithm and a refined algorithm for the following problem: Display the square of numbers from 0 to some user inputted value. For example if the user enters 3 then the program will need to display the square of 0, 1, 2 and 3. Must use a counter loop. Must use 2 methods. One method that gets the number from the user and returns it. A second method is passed that number as a parameter...
Creating a list/tuple 4. Write a program to accept a string from the user, then replace...
Creating a list/tuple 4. Write a program to accept a string from the user, then replace the first letter with the last letter, the last letter with the middle letter and the middle letter with the first letter. E.g. “Billy” -> “yiBll”.
Use the following balance sheet for Delta Company to answer the following 4 questions. Assets Liabilities...
Use the following balance sheet for Delta Company to answer the following 4 questions. Assets Liabilities and owners equity Cash 600 Accounts Payable 700 Inventory 80 Notes Payable 200 Accounts Receivable 400 Current Maturing LTD 40 Fixed assets 1500 Stock 1300 Accumulated Depreciation (90) Retained Earnings 250 Total 2490 Total 2490 Which of the following statements is accurate in regards to Delta's financial position? Delta's NWC suggests that solvency is a concern. Delta's NWC suggests that the firm has a...
Write a program to perform the following two tasks: 1. The program will accept a string...
Write a program to perform the following two tasks: 1. The program will accept a string as input in which all of the words are run together, but the first character of each word is uppercase. Convert the string to a string in which the words are separated by spaces and only the first word starts with an uppercase letter. For example, the string "StopAndSmellTheRose" would be converted to "Stop and smell the rose". Display the result string. 2. Then...
Write a program to perform the following two tasks: 1. The program will accept a string...
Write a program to perform the following two tasks: 1. The program will accept a string as input in which all of the words are run together, but the first character of each word is uppercase. Convert the string to a string in which the words are separated by spaces and only the first word starts with an uppercase letter. For example, the string "StopAndSmellTheRose" would be converted to "Stop and smell the rose". Display the result string. 2. Then...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT