# INF 260 - 002 – Object-Oriented Programming - I - Fall 2012 Proje.docx

A

INF 260 - 002 – Object-Oriented Programming - I - Fall 2012 Project #2 *Due 11/5/2012, Monday, 10:00AM IMPORTANT: You can use any IDE for creating your programs. Create the programs and save them. Compile and run the programs. Save the screenshot of the successfully run programs and submit the screenshots with the corresponding source code files . Programs should be well-commented to make their understanding easy. Variable-names should be so chosen that it is easily to visualize what is going on. 7.14/256 (Exploring matrix) Write a program that prompts the user to enter of a square matrix, randomly fills in 0s and 1s into the matrix, prints the matrix, finds the row, columns, and diagonals with all 0s or 1s. Here is a sample run of the program. Enter the size for the matrix: 4 —Enter 0111 0000 0100 1111 All 0s on row 1 All 1s on row 3 No same numbers on a column No same numbers on the major diagonal No same numbers on the sub-diagonal 20x1 7.17/257-258 (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. Figure 7.8 is a diagram that shows five banks. The banks' current balances are 25, 125, 175, 75, and 1.81 million dollars, respectively. The directed edge from node 1 to node 2 indicates that bank 1 lends 40 million dollars to bank 2. FIGURE 7.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 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 is 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 7.8 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 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). So, bank 1 is also unsafe. The output of the program should be Unsafe banks are 3 1 (Hint: Use a two-dimensional array borrowers to represent borrowers[i][j] indicates the loan that bank i loans to bank j. Once becomes unsafe, borrowers[i][j] s.

Programming - C++Aoun10
112 views5 Folien

## Similar a INF 260 - 002 – Object-Oriented Programming - I - Fall 2012 Proje.docx

Assignment#09Sunita Milind Dol
1.4K views4 Folien

## Más de altheaboyer

### Último(20)

Gopal Chakraborty Memorial Quiz 2.0 Prelims.pptx
Debapriya Chakraborty221 views
Industry4wrd.pptx
BC Chew153 views
Scope of Biochemistry.pptx
shoba shoba110 views
Drama KS5 Breakdown
WestHatch50 views
ICS3211_lecture 08_2023.pdf
Vanessa Camilleri68 views
discussion post.pdf
jessemercerail70 views
Chemistry of sex hormones.pptx
RAJ K. MAURYA97 views
Psychology KS5
WestHatch53 views
Narration ppt.pptx
Tariq KHAN62 views
ACTIVITY BOOK key water sports.pptx
Mar Caston Palacio132 views
Narration lesson plan.docx
Tariq KHAN90 views
Dance KS5 Breakdown
WestHatch52 views
Sociology KS5
WestHatch50 views
CWP_23995_2013_17_11_2023_FINAL_ORDER.pdf
SukhwinderSingh895865467 views
Streaming Quiz 2023.pdf
Quiz Club NITW87 views
Universe revised.pdf
DrHafizKosar84 views
STERILITY TEST.pptx
Anupkumar Sharma102 views

### INF 260 - 002 – Object-Oriented Programming - I - Fall 2012 Proje.docx

• 1. INF 260 - 002 – Object-Oriented Programming - I - Fall 2012 Project #2 *Due 11/5/2012, Monday, 10:00AM IMPORTANT: You can use any IDE for creating your programs. Create the programs and save them. Compile and run the programs. Save the screenshot of the successfully run programs and submit the screenshots with the corresponding source code files . Programs should be well-commented to make their understanding easy. Variable-names should be so chosen that it is easily to visualize what is going on. 7.14/256 (Exploring matrix) Write a program that prompts the user to enter of a square matrix, randomly fills in 0s and 1s into the matrix, prints the matrix, finds the row, columns, and diagonals with all 0s or 1s. Here is a sample run of the program. Enter the size for the matrix: 4 —Enter 0111 0000 0100 1111
• 2. All 0s on row 1 All 1s on row 3 No same numbers on a column No same numbers on the major diagonal No same numbers on the sub-diagonal 20x1 7.17/257-258 (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. Figure 7.8 is a diagram that shows five banks. The banks' current balances are 25, 125, 175, 75, and 1.81 million dollars, respectively. The directed edge from node 1 to node 2 indicates that bank 1 lends 40 million dollars to bank 2. FIGURE 7.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 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 is 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
• 3. 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 7.8 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 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). So, bank 1 is also unsafe. The output of the program should be Unsafe banks are 3 1 (Hint: Use a two-dimensional array borrowers to represent borrowers[i][j] indicates the loan that bank i loans to bank j. Once becomes unsafe, borrowers[i][j] should be set to 0.) 20x1 8.1/296 (The Rectangle class) Following the example of the Circle class in 8.2, design a class named Rectangle to represent a rectangle. The class contains: · Two double data fields named width and height that specify the wid and height of the rectangle. The default values are 1 for
• 4. both width and height. · A no-arg constructor that creates a default rectangle. · A constructor that creates a rectangle with the specified width and height. · A method named getArea() that returns the area of this rectangle. · A method named getPerimeter() that returns the perimeter. Implement the class. Write a test program that creates two Rectangle objects—one with width 4 and height 40 and the other with width 3.5 and height 35.9. Display the width, height, area and perimeter of each rectangle in this order. 20x1 8.7/297 (The Account class) Design a class named Account that contains: · A private int data field named id for the account (default 0). · A private double data field named balance for the account (default 0). · A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. · A private Date data field named dateCreated that stores the date when the account was created.
• 5. · A no-arg constructor that creates a default account. · A constructor that creates an account with the specified id and initial balance. · The accessor and mutator methods for id, balance, and annualInterestRate. · The accessor method for dateCreated. · A method named getMonthlyInterestRate() that returns the monthly interest rate. · A method named withdraw that withdraws a specified amount from the account. · A method named deposit that deposits a specified amount to the account. Implement the class. Write a test program that creates an Account object with an account ID of 1122, a balance of \$20,000, and an annual interest rate of 4.5%. Use the withdraw method to withdraw \$2,500, use the deposit method to deposit \$3,000, and print the balance, the monthly interest and the date when this account was created. 20x1 PS: Be sure to follow the instructions related to Input/Output, coding conventions, directions on comments, naming conventions, indentation, spacing, block styles and what to turn in – as specified after assignment 1 while writing your programs.
• 6. *** i will pay whatever it takes
Aktuelle SpracheEnglish
Español
Portugues
Français
Deutsche