JAC444 – Solved

$ 20.99
Category:

Description

Workshop 3
Notes:
i. Each task should be presented during the lab, demo worth 70% of the workshop marks and code uploading worth the other 30%.
ii. Make sure you have all security and check measures in place, like wrong data types etc., no need to implement Exception as we haven’t covered yet. There are other ways to handle bad input data.
iii. Given output structure is just for student to have a glimpse what the output can look, student are free to make the output better in any way.
iv. The final should be submitted by the midnight to avoid late penalties which are 10% each day late.

Other inputs can be given during demo, so make sure you test your program properly.

Task 1: Design a new Triangle class that extends the abstract GeometricObject class (provided in Lecture 3). Provide the UML diagram for the classes Triangle and GeometricObject and then implement the Triangle class.
Write a test program that prompts the user to enter three sides of the triangle, a color, and a Boolean value to indicate whether the triangle is filled. The program should create a Triangle object with these sides and set the color and filled properties using the input. The program should display the area, perimeter, color, and true or false to indicate whether it is filled or not.

Task 2:

Banks lend money to each other

Write a program to find all the unsafe banks. Your program reads the input as follows.
1. It first reads two integers n and limit, where n indicates the number of banks and limit is the minimum total assets for keeping a bank safe from the user.
2. 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 above picture is as follows (note that the limit is 201):

Number of banks: 5
Minimum asset limit: 201
Bank # 0 → Balance: 25 → Number of banks Loaned: 2 → Bank ID: 1 → Amount: 100.5 → Bank ID: 4 → Amount: 320.5
Bank # 1 → Balance: 125 → Number of banks Loaned: 2 → Bank ID: 2 → Amount: 40 → Bank ID: 3 → Amount: 85
Bank # 2 → Balance: 175 → Number of banks Loaned: 2 → Bank ID: 0 → Amount: 125 → Bank ID: 3 → Amount: 75
Bank # 3 → Balance: 75 → Number of banks Loaned: 1 → Bank ID: 0 → Amount: 125
Bank # 4 → Balance: 181 → Number of banks Loaned: 1 → Bank ID: 2 → Amount: 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.
Note: Program should take inputs from the user like Number of banks, Minimum asset limit and then all other inputs

The output of the program should be
Unsafe banks are 3 and Bank 1

Reviews

There are no reviews yet.

Be the first to review “JAC444 – Solved”

Your email address will not be published. Required fields are marked *