Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You have given a StarterPack for this assignment. It is an incomplete project, you should modify it to satisfy all the requirements of question bellow,

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
You have given a StarterPack for this assignment. It is an incomplete project, you should modify it to satisfy all the requirements of question bellow, Your midterm will also follow the same format so make yourself comfortable with importing projects to your IDE. There are parts in the starter pack that are complete and does not need any modification, these parts are given to you to test your code and help you with the overall structure of your program. 1. In chapter 4 , we discussed a bank account example. Modify the account class to meet the following requirements: a. Change the constructor to assign random account numbers in the range of [10000, 20000 ] instead of asking the user to input it in the constructor call. b. Verify withdrawal before it occurs. The withdrawal amount + fee must not exceed the current balance of the account. If the withdrawal cannot take place, a message should be displayed to the user: "Transaction unsuccessful, insufficient balance." c. If the balance of any account falls below $25.00, a text output must appear on the console. The output should use the owner's name to identify the account we are referring to. The message should be: "[Owner's name] account balance is now less than $25.00." d. If the balance exceeds $4,000.00, a text output must appear on the console stating that the owner is eligible to apply for a credit card. The message should be: "[Owner's name] is now eligible to apply for a credit card" Note1: There may be more than one way to increase the balance we only want to see eligibility message once, for each account on the first time it gets eligible. Note2: If balance falls below $4,000.00 the client will NOT lose the eligibility e. When an account is created, a welcome message should be displayed on the console in the following format: "Account [Account Number] , [Owner's name] has been created with initial balance of [balance] ] If the initial balance is over $4,000.00, the message should be as follows: "Account [Account Number] , [Owner's name] has been created with initial balance of [balance] and is eligible to apply for a credit card" Hint: create a method called welcome() and call it in the constructor. f. Remove the addinterest() method and create a new method called endOfYear(). This method should perform the following functions: i. It should remove an annual fee of $15.00 for accounts with a balance less than $2,000.00 and $25.00 for accounts with a balance greater than $2,000.00 ii. If the account's balance gets less than $0.00 put balance to $0.00 and display: "[Owner's name] account has been suspended." iii. It should add the interest as previously done by addinterest() method. The order of execution of (i), (ii) and (iii) is important! g. Modify the toString() method such that when the object is printed, it shows whether the owner is eligible for a credit card or not. [Account Number] [Owner's name] [Balance] [Eligible/ineligible for credit card] - Note that your code must be readable, well commented and enforce encapsulation, methods that does not need to be invoked by the client should not be declared public. If you are reporting monetary value, it must be formatted properly. - The transactions class is just for testing your program, modification over it will not result in any mark. All the changes must be done on Account class. 2. The purpose of the program in this question is to determine if the year is a leap year (and therefore has 29 days in February) in the Gregorian calendar. A year is a leap year if it is divisible by 4 , unless it is also divisible by 100 but not 400 . For example, the year 2003 is not a leap year, but 2004 is. The year 1900 is not a leap year because it is divisible by 100 , but the year 2000 is a leap year because even though it is divisible by 100 , it is also divisible by 400 . Produce an error message for any input value less than 1582 (the year the Gregorian calendar was adopted). The user should be able to evaluate multiple years. Allow the user to terminate the program using an appropriate sentinel value. Validate each input value to ensure it is greater than or equal to 1582. 3. You are designing a simple game where a player can move their character around a gridbased map. The player's character can move up, down, left, or right one square at a time. The player wins the game if they can reach a specific location on the map. Create three classes: GameMap, Player and, Game. The GameMap class should have the following attributes and methods: - int mapSize - the size of the map (assume the map is square) - int targetRow - the row where the target location is - int targetCol - the column where the target location is - boolean isTarget(int row, int col) - returns true if the given row and column correspond to the target location, false otherwise The Player class should have the following attributes and methods: - int row - the current row of the player's character - int col - the current column of the player's character - void moveUp()-moves the player's character up one square - void moveDown() - moves the player's character down one square - void moveleft() - moves the player's character left one square - void moveRight() - moves the player's character right one square - boolean isAtTarget() - returns true if the player's character is at the target location, false otherwise The GameMap class should have a constructor that takes the size of the map and the row and column of the target location as arguments. The Player class should have a constructor that takes the starting row and column of the player's character as arguments. Implement the classes so that the Player can move around the map and win the game if they reach the target location. The Player should not be able to move off the edges of the map, and the GameMap class should not allow the player to move through walls or other obstacles. Use encapsulation to ensure that the internal state of the classes cannot be modified directly. Use a nested while loop to allow the player to repeatedly input directions until the game is won or lost. The Player will have 10 turns to find the target, If the player reaches the target location, print a message indicating that they won if it can't reach in less than 10 turns print that the player is lost. The Player should not be allowed to exceed the boundaries of the map, if tried, the player should not move but will lose a turn. To accomplish that move the map object. should be passed to the moveDown[) and moveRight () method. The player should always see the position in the console, you should use proper printing commands to accomplish that. In the following examples the target is located at (3,3) Example one: [LOSE SCENARIO] an example is provided here: Enter direction (u/d/l/r):r Enter direction (u/d/I/r):r . P.- Enter direction (u/d/I/r):r .. P. Enter direction (u/d/I/r):r .P Enter direction (u/d/I/r):d ... P Enter direction (u/d/I/r):d P + Enter direction (u/d/I/r):d Enter direction (u/d/I/r):d =P Enter direction (u/d/l/r):d .... P Enter direction (u/d/l/r):d You lose! Example two: [WIN SCENARIO] Enter direction (u/d/I/r):r P. . Enter direction (u/d/I/r):r P - ) Enter direction (u/d/I/r):r You have given a StarterPack for this assignment. It is an incomplete project, you should modify it to satisfy all the requirements of question bellow, Your midterm will also follow the same format so make yourself comfortable with importing projects to your IDE. There are parts in the starter pack that are complete and does not need any modification, these parts are given to you to test your code and help you with the overall structure of your program. 1. In chapter 4 , we discussed a bank account example. Modify the account class to meet the following requirements: a. Change the constructor to assign random account numbers in the range of [10000, 20000] instead of asking the user to input it in the constructor call. b. Verify withdrawal before it occurs. The withdrawal amount + fee must not exceed the current balance of the account. If the withdrawal cannot take place, a message should be displayed to the user: "Transaction unsuccessful, insufficient balance." c. If the balance of any account falls below $25.00, a text output must appear on the console. The output should use the owner's name to identify the account we are referring to. The message should be: "[Owner's name] account balance is now less than $25.00." d. If the balance exceeds $4,000.00, a text output must appear on the console stating that the owner is eligible to apply for a credit card. The message should be: "[Owner's name] is now eligible to apply for a credit card" Note1: There may be more than one way to increase the balance we only want to see eligibility message once, for each account on the first time it gets eligible. Note2: If balance falls below $4,000.00 the client will NOT lose the eligibility e. When an account is created, a welcome message should be displayed on the console in the following format: "Account [Account Number] , [Owner's name] has been created with initial balance of [balance]" If the initial balance is over $4,000.00, the message should be as follows: "Account [Account Number] , [Owner's name] has been created with initial balance of [balance] and is eligible to apply for a credit card" Hint: create a method called welcome() and call it in the constructor. f. Remove the addinterest() method and create a new method called endOfYear(). This method should perform the following functions: i. It should remove an annual fee of $15.00 for accounts with a balance less than $2,000.00 and $25.00 for accounts with a balance greater than $2,000.00 ii. If the account's balance gets less than $0.00 put balance to $0.00 and display: "[Owner's name] account has been suspended." iii. It should add the interest as previously done by addinterest() method. The order of execution of (i), (ii) and (iii) is important! g. Modify the toString() method such that when the object is printed, it shows whether the owner is eligible for a credit card or not. [Account Number] [Owner's name] [Balance] [Eligible/ineligible for credit card] - Note that your code must be readable, well commented and enforce encapsulation, methods that does not need to be invoked by the client should not be declared public. If you are reporting monetary value, it must be formatted properly. - The transactions class is just for testing your program, modification over it will not result in any mark. All the changes must be done on Account class. 2. The purpose of the program in this question is to determine if the year is a leap year (and therefore has 29 days in February) in the Gregorian calendar. A year is a leap year if it is divisible by 4 , unless it is also divisible by 100 but not 400 . For example, the year 2003 is not a leap year, but 2004 is. The year 1900 is not a leap year because it is divisible by 100 , but the year 2000 is a leap year because even though it is divisible by 100 , it is also divisible by 400 . Produce an error message for any input value less than 1582 (the year the Gregorian calendar was adopted). The user should be able to evaluate multiple years. Allow the user to terminate the program using an appropriate sentinel value. Validate each input value to ensure it is greater than or equal to 1582. 3. You are designing a simple game where a player can move their character around a gridbased map. The player's character can move up, down, left, or right one square at a time. The player wins the game if they can reach a specific location on the map. Create three classes: GameMap, Player and, Game. The GameMap class should have the following attributes and methods: - int mapSize - the size of the map (assume the map is square) - int targetRow - the row where the target location is - int targetCol - the column where the target location is - boolean isTarget(int row, int col) - returns true if the given row and column correspond to the target location, false otherwise The Player class should have the following attributes and methods: - int row - the current row of the player's character - int col - the current column of the player's character - void moveUp() - moves the player's character up one square - void moveDown() - moves the player's character down one square - void moveleft() - moves the player's character left one square - void moveRight() - moves the player's character right one square - boolean isAtTarget() - returns true if the player's character is at the target location, false otherwise Enter direction (u/d/I/r):r . P . . Enter direction (u/d/I/r):r ... P. Enter direction (u/d/I/r):r .P Enter direction (u/d/I/r):d ... P Enter direction (u/d/I/r):d p ... . Enter direction (u/d/I/r):d 2. The purpose of the program in this question is to determine if the year is a leap year (and therefore has 29 days in February) in the Gregorian calendar. A year is a leap year if it is divisible by 4 , unless it is also divisible by 100 but not 400 . For example, the year 2003 is not a leap year, but 2004 is. The year 1900 is not a leap year because it is divisible by 100 , but the year 2000 is a leap year because even though it is divisible by 100 , it is also divisible by 400 . Produce an error message for any input value less than 1582 (the year the Gregorian calendar was adopted). The user should be able to evaluate multiple years. Allow the user to terminate the program using an appropriate sentinel value. Validate each input value to ensure it is greater than or equal to 1582. 3. You are designing a simple game where a player can move their character around a gridbased map. The player's character can move up, down, left, or right one square at a time. The player wins the game if they can reach a specific location on the map. Create three classes: GameMap, Player and, Game. The GameMap class should have the following attributes and methods: - int mapSize - the size of the map (assume the map is square) - int targetRow - the row where the target location is - int targetCol - the column where the target location is - boolean isTarget(int row, int col) - returns true if the given row and column correspond to the target location, false otherwise The Player class should have the following attributes and methods: - int row - the current row of the player's character - int col - the current column of the player's character - void moveUp() - moves the player's character up one square - void moveDown() - moves the player's character down one square - void moveleft() - moves the player's character left one square - void moveRight() - moves the player's character right one square - boolean isAtTarget() - returns true if the player's character is at the target location, false otherwise

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1. Are my sources credible?

Answered: 1 week ago

Question

3. Are my sources accurate?

Answered: 1 week ago

Question

1. Is it a topic you are interested in and know something about?

Answered: 1 week ago