Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 8, Problem 8.17PE

(Financial tsunami) Banks lend money to each other. In tough economic times, if a bank goes bankrupt, it may not be able to pay back the loan. A bank’s total assets are its current balance plus its loans to other banks. The diagram in Figure 8.8 shows five banks. The banks’ current balances are 25, 125, 175, 75, and 181 million dollars, respectively. The directed edge from node 1 to node 2 indicates that bank I lends 40 million dollars to bank 2.

Chapter 8, Problem 8.17PE, (Financial tsunami) Banks lend money to each other. In tough economic times, if a bank goes

figure 8.8 Banks lend money to each other.

If a bank’s total assets are under a certain Limit, the bank is unsafe. The money it borrowed cannot be returned to the lender, and the lender cannot count the loan in its total assets. Consequently, the lender may also be unsafe, if its total assets are under the Limit. Write a program to find all the unsafe banks. Your program reads the input as follows. It first reads two integers n and 1 i mit, where n indicates the number of banks and limit is the minimum total assets for keeping a bank safe. It then reads n Lines that describe the information for n banks with IDs from 0 to n-1. The first number in the line is the bank’s balance, the second number indicates the number of banks that borrowed money from the bank, and the rest are pairs of two numbers. Each pair describes a borrower. The first number in the pair is the borrower’s ID and the second is the amount borrowed. For example, the input for the five banks in Figure 8.8 is as follows (note the limit is 201):

5 201

25 2 1 100.5 4 320.5

125 2 2 40 3 85

175 2 0 125 3 75

75 1 0 125

181 1 2 125

The total assets of bank 3 are (75 + 125), which is under 201, so bank 3 is unsafe. After bank 3 becomes unsafe, the total assets of bank 1 fall below (125 + 40). Thus, bank 1 is also unsafe. The output of the program should be

Un safe banks are 3 1

(Hint: Use a two-dimensional array borrowers to represent loans. borrowers [i] [j] indicates the loan that bank i provides to bank j . Once bank j becomes unsafe, borrowers[i] [j] should be set to 0.)

Blurred answer
Students have asked these similar questions
Calculate the following transitive closures
Part 2: Binary Arithmetic One of the most common operations we perform on binary numbers (and all numbers) is addition. It can be cumbersome to convert your binary numbers to decimal just to add them and convert them back, so instead we will be learning how to add binary numbers directly. Binary addition works the same way as decimal addition, with the added restriction that each digit can only go up to 1. Let's consider the possibilities for adding the values of any 2 single digits together: 0 + 0 0 + 1 1 + 0 1 + 1 0 1 1 10 (remember that 10 in binary represents the number 2) In that last case, the result is larger than a single digit. When adding larger binary numbers, that means we have to carry the 1 over to the next column. This presents us with another new case: what happens if we have 1 + 1 + carried 1? In that case, the result is 11, which means that column's result is 1, and we carry 1 to the next column. Below is an example of adding two binary numbers that shows all…
Task 4: The first problem that you solve recursively is to implement enoughGate() to check if the dogMaze has at least two gates (one for the entrance and one for the exit). This problem must be solved recursively, however there is no limitation on what type of recursion (i.e., direct or indirect recursion) you use . As a reminder, a direct recursion refers to the function that calls itself to solve the given problem. However, by indirect recursion, more than one function involves in solving the problem. It is possible that a non-recursive function solves a small part of the problem and then calls the recursive function to finish the job.   /** * This method returns true if the number of  * gates in dogMaze >= 2.  * @return it returns true, if enough gate exists (at least 2), otherwise false. */ publicboolean enoughGate (){ // insert your code here. Change the return value to fit your purpose.  return true; }

Chapter 8 Solutions

Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)

Ch. 8.8 - Declare an array variable for a three-dimensional...Ch. 8.8 - Assume char[][][] x =new char[12][5][2], how many...Ch. 8.8 - Show the output of the following code: int[][][]...Ch. 8 - (Sum elements column by column) Write a method...Ch. 8 - (Sum the major diagonal in a matrix) Write a...Ch. 8 - (Sort students on grades) Rewrite Listing 8.2,...Ch. 8 - (Compute the weekly hours for each employee)...Ch. 8 - (Algebra: add two matrices) Write a method to add...Ch. 8 - (Algebra: multiply two matrices) Write a method to...Ch. 8 - (Points nearest to each other) Listing 8.3 gives a...Ch. 8 - (All closest pairs of points) Revise Listing 8.3,...Ch. 8 - Prob. 8.9PECh. 8 - (Largest row and column) Write a program that...Ch. 8 - (Game: nine heads and tails) Nine coins are placed...Ch. 8 - (Financial application: compute tax) Rewrite...Ch. 8 - (Locate the largest element) Write the following...Ch. 8 - (Explore matrix) Write a program that prompts the...Ch. 8 - (Geometry: same line ?) Programming Exercise 6.39...Ch. 8 - (Sort two-dimensional array) Write a method to...Ch. 8 - (Financial tsunami) Banks lend money to each...Ch. 8 - (Shuffle rows) Write a method that shuffles the...Ch. 8 - (Pattern recognition: four consecutive equal...Ch. 8 - Prob. 8.20PECh. 8 - (Central city) Given a set of cities, the central...Ch. 8 - (Even number of 1s) Write a program that generates...Ch. 8 - (Game: find the flipped cell) Suppose you are...Ch. 8 - (Check Sudoku solution) Listing 8.4 checks whether...Ch. 8 - Prob. 8.25PECh. 8 - (Row sorting) Implement the following method to...Ch. 8 - (Column sorting) Implement the following method to...Ch. 8 - (Strictly identical arrays) The two-dimensional...Ch. 8 - (Identical arrays) The two-dimensional arrays m1...Ch. 8 - (Algebra: solve linear equations) Write a method...Ch. 8 - (Geometry: intersecting point) Write a method that...Ch. 8 - (Geometry: area of a triangle) Write a method that...Ch. 8 - (Geometry: polygon subareas) A convex four-vertex...Ch. 8 - (Geometry: rightmost lowest point) In...Ch. 8 - (Largest block) Given a square matrix with the...Ch. 8 - (Latin square) A Latin square is an n-by-n array...Ch. 8 - (Guess the capitals) Write a program that...

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY