http://www.cise.ufl.edu/class/cop3502sp12/Files/PA4.pdf ^Instructions Write a pr
ID: 3640555 • Letter: H
Question
http://www.cise.ufl.edu/class/cop3502sp12/Files/PA4.pdf^Instructions
Write a program to find all unsafe banks. Your program reads the input as
follows. It first reads two integers n and limit, where n indicates the number of
banks and limit the minimum total assets for keeping a bank safe. It then reads
n lines that describe the information for n banks with id 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 1 is as follows (note that 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 program has to be in this format. Thanks
Explanation / Answer
import java.util.Scanner; public class Test { public static void main(String[] args){ Scanner input= new Scanner(System.in); System.out.print(" Enter Number Of Banks and minimum assets for keeping a bank safe : "); int n = input.nextInt(); int limit = input.nextInt(); System.out.print(" Now enter the bank's balance, the number of banks that borrowed money from the bank," + (" and the borrower's i.d along with the amount borrowed : ")); double[] balance = new double[n]; double[][][] borrowers = new double [n][n][n]; boolean isSafe[]= new boolean[n]; for (int i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.