Case 1:
o For each question:
o I will compile your .java files. If any compilation error occurs, 5 pts
will be deducted.
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 You can only use the techniques that you have learned so far. Other
techniques will not be accepted. For other techniques, 10 pts will be
deducted.
o Do not drag and drop components. It is not acceptable. You will get 0
point.
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 3 pts will be deducted.
• Case 2:
o For each question:
o If there is not any compilation error:
▪ I will try each case scenario as 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.
▪ You can only use the techniques that you have learned so far. Other
techniques will not be accepted. For other techniques, 10 pts will
be deducted.
▪ 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 3 pts 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.
QUESTIONS
Note: In each question, assume that the user enters correct inputs. You can drag and drop components.
UPLOAD
• AccountSavings.java
• Person.java
• PersonTest.java
• YourFirstNameYourLastName.zip / YourFirstNameYourLastName.rar
1. (50 pts) Create a class AccountSavings. The class has two instance variables: a double variable to keep annual interest rate and a double variable to keep savings balance. The annual interest rate is 5.3 and savings balance is $100.
• Create a method to calculate monthly interest.
• Create a method to run two threads. Use anonymous classes to create these threads. The first thread calls the monthly interest calculation method 12 times, and then displays the savings balance (the balance in 12nd month). After that, this thread sleeps 5
seconds. The second thread calls the monthly interest calculation method 12 times, and then displays the savings balance (the balance in 12nd month). Before the main thread ends, these two threads must be completed.
• Add your main method into the same class and test your threads. After these two threads are executed, the savings balance must remain same.
2. (50 pts) Create a class Person. A person has a first name and a last name. Create a constructor for the person. Use the interface Runnable to create a thread from the class Person. This thread displays a message that the given person is started to work (display his/her first name and last name). Then, the thread sleeps 5 seconds. And then, the thread displays that the given person is completed its job (display his/her first name and last name).
Then, create a class PersonTest. Use executor services to create a thread pool with a size of 3. Then, submit 4 Person threads. In the main thread, display a message that the all tasks are submitted, and display that all tasks are done.