1 INSY 4305 ADVANCED APPLICATION DEVELOPMENT ASSINGMENT 4 20 points 1. INSTRUCTIONS • For the late submissions, 2% of the total points will be deducted per hour automatically on Canvas. • PLEASE, ONLY...

1 answer below »
java assignment, 2 questions


1 INSY 4305 ADVANCED APPLICATION DEVELOPMENT ASSINGMENT 4 20 points 1. INSTRUCTIONS • For the late submissions, 2% of the total points will be deducted per hour automatically on Canvas. • PLEASE, ONLY USE TECHNIQUES THAT WE LEARNED IN CHAPTER 8 AND CHAPTER 9. • If you use other techniques, 4 pts will be deducted. • In this assignment, you are expected to create upload one .zip/.rar file including five Java applications. o YourFirstNameLastName.zip/.rar [including AccountSavings.java, AccountSavingsTest.java, Person.java, Teacher.java, PersonTest.java] • Each question is independent of each other. • Do not forget to add comments to explain how your codes are working! Short comments are acceptable. • Write your codes individually! Do not copy of any of them from someone else! • NOTE: If you are using any IDE (Netbeans, Eclipse, etc.), please delete the statement package xxxxx; (and save it again), from your application. Otherwise, I will get a compilation error, and you will lose 1 pt for each file giving a compilation error. It is your responsibility. 2 2. GRADING POLICY • Case 1: o For each question: o I will compile your .java files. If any compilation error occurs, 1 pt will be deducted for each file including a compilation error. o After that, I will check your algorithms whether they are correct or not. For example; if it says find odd and even numbers. I will check whether it really finds both even and odd numbers. This part will be evaluated based on your work. o Additionally, comments will be checked whether they clearly and briefly explain what you have done. If comments are missing or not clear, enough, or brief 1 pt will be deducted. o • Case 2: o For each question: o If there is not any compilation error: ▪ I will try each case scenario stated in each question. For example; if it says find odd and even numbers. I will try both even and odd numbers. This part will be evaluated based on your work. ▪ Additionally, comments will be checked whether they clearly and briefly explain what you have done. If comments are missing or not clear, enough, or brief 1 pt will be deducted. • Case 3: o If you do not upload a .java file, I will not evaluate your answer. • Case 4: o If it is determined that you copy the codes from someone else, you will get 0 pt. 3 QUESTIONS 1. (10 pts) Create a class named AccountSavings. This class has a static double variable which stores the annual interest rate for all account holders. The name of variable is annualInterestRate. The class also has another double variable named savingsBalance which stores balance for current account. a. Write a constructor to create an account with specified balance. Add a validation whether the balance is greater than 0.0 or not. If it is less than 0.0 then throw illegal argument exception. b. Write a non-static calculateMonthlyInterest method to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12 – the interest should be added to savingsBalance. c. Write a static method named modifyInterestRate to set the annual interest rate. Add a validation whether the rate is greater than equal to 0.0 and less than or equal 1.0. Otherwise, throw illegal argument exception. d. Write a toString method which returns savingsBalance in a string format. After that, create AccountSavingsTest class. Create two objects from the class AccountSavings with balances $2000.00 and $3000.00. Then, set the interest rate to 4%, then calculate the monthly interest rate for each 12 months for each object and print the new balances with toString method for each object. UPLOAD AccountSavings.java AND AccountSavingsTest.java. Example Output: (you can create a similar output) 4 2. (10 pts) Create a class Person which is a super class. The class includes four private String instance variables: first name, last name, social security number, and state. Write a constructor and get methods for each instance variable. Also, add a toString method to print the details of the person. After that create a class Teacher which extends the class, Person. Add a private instance variable to store number of courses. Write a constructor and a get method for the number of courses and override toString method for Teacher. Then, create PersonTest class and create an object from the class Teacher and an object from the class Person. Display the details of Teacher and Person (use toString methods). UPLOAD Person.java AND Teacher.java AND PersonTest.java. Example Output:
Answered Same DayApr 06, 2021

Answer To: 1 INSY 4305 ADVANCED APPLICATION DEVELOPMENT ASSINGMENT 4 20 points 1. INSTRUCTIONS • For the late...

Neha answered on Apr 14 2021
149 Votes
53576/AccountSavings.java
53576/AccountSavings.java
public class AccountSavings{
    private static double annualInterestRate = 0
.0f;
    private double savingsBalance = 0.0f;
    // constructor
    public SavingsAccount(double savingsBalance){
        if(savingsBalance<0)
        {
            throw new IllegalArgumentException("The amount can't be less than 0");
        }
        setSavingsBalance(savingsBalance);
    }
    // SETTERS
    public void setSavingsBalance(double savingsBalance){
        this.savingsBalance = savingsBalance;
    }
    // update the interest rate
    public static void modifyInterestRate(double newInterestRate){
        // check for negative interest rates
        if(newInterestRate >= 0.0f)
            annualInterestRate = newInterestRate;
        else
            throw new IllegalArgumentException("Interest rate must be >= 0.0f");
    }
    // GETTERS
    public double getSavingsBalance(){
        return this.savingsBalance;
    }
    public static double getAnnualInterestRate(){
        return annualInterestRate;
    }
    // calculates the monthly interest and update the savings balance
    public void calculateMonthlyInterest(){
        savingsBalance += (savingsBalance * annualInterestRate) / 12;
    }
    // return savingsBalance as...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here