diff options
Diffstat (limited to 'src/Q2')
| -rw-r--r-- | src/Q2/README.md | 146 |
1 files changed, 118 insertions, 28 deletions
diff --git a/src/Q2/README.md b/src/Q2/README.md index 2335548..640aed3 100644 --- a/src/Q2/README.md +++ b/src/Q2/README.md @@ -15,6 +15,119 @@ I. An employee has committed to save $2000 per month. Her quarterly savings are as follows: +* Q1 – $5000 +* Q2 – $7000 +* Q3 – $4000 +* Q4 – $8000 + +II. Another employee has committed to save $3000 per month. +His quarterly savings are as follows: + +* Q1 – $6000 +* Q2 – $9000 +* Q3 – $10000 +* Q4 – $17000 + +Write a program to compute the total bonus amount earned by these two employees in the year. + +2. Description of the Code: + +I created a class that implemented the interface described in the +assignment. To calculate the bonus for the year I created a method +called `quarterlyBonus` to calculate the bonus for each month. I also +created a method called `annualBonus` to calculate the additional bonus +for the annual target. Then I summed the quarterly bonuses with the +annual bonus to calculate the final bonus amount. + +3. Errors and Warnings: + +```bash +モ mvn test +[INFO] Scanning for projects... +[INFO] +[INFO] -------------------< ca.mokhan.comp268:assignment1 >-------------------- +[INFO] Building assignment1 1.0-SNAPSHOT +[INFO] --------------------------------[ jar ]--------------------------------- +[INFO] +[INFO] --- fmt-maven-plugin:2.8:format (default) @ assignment1 --- +[INFO] Processed 48 files (0 reformatted). +[INFO] +[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ assignment1 --- +[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! +[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/main/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ assignment1 --- +[INFO] Changes detected - recompiling the module! +[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! +[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/classes +[INFO] +[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ assignment1 --- +[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! +[INFO] skip non existing resourceDirectory /Users/mokha/development/gh/comp-268/src/test/resources +[INFO] +[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ assignment1 --- +[INFO] Changes detected - recompiling the module! +[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! +[INFO] Compiling 24 source files to /Users/mokha/development/gh/comp-268/target/test-classes +[INFO] +[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ assignment1 --- +[INFO] Surefire report directory: /Users/mokha/development/gh/comp-268/target/surefire-reports + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running ca.mokhan.comp268.AppTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec +Running ca.mokhan.test.CandidateTest +Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.053 sec +Running ca.mokhan.test.NumberTest +Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.021 sec +Running ca.mokhan.test.EmployeeSavingsTest +Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 sec +Running ca.mokhan.test.CartesianCoordinateSystemTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.CommunicationTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.TaxReturnTest +Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.BanffMarathonRunnerTest +Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec +Running ca.mokhan.test.AddressBookTest +Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.TriangleTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.BonusOnSavingsTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec +Running ca.mokhan.test.HailstoneSequenceTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec + +Results : + +Tests run: 52, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 2.871 s +[INFO] Finished at: 2019-05-13T20:07:42-06:00 +[INFO] ------------------------------------------------------------------------ +``` + + +4. Sample Input and Output: +[Provide some test cases with sample input and output of your program.] + +The test cases can be found in `BonusOnSavingsTest.java`. + +5. Discussion: + +I manually calculated the expected bonuses to make sure that I +understood the problem and how to calculate a result. + +Employee 1 + +Her quarterly savings are as follows: + Q1 – $5000 Q2 – $7000 Q3 – $4000 @@ -31,8 +144,7 @@ Y1: $24,000.00 meets the annual minimum. $24,000.00 * 5% = $1,200.00 Total bonus: 210 + 240 + 1200 = $1,650.00 -II. Another employee has committed to save $3000 per month. -His quarterly savings are as follows: +Employee 2 Q1 – $6000 Q2 – $9000 @@ -53,29 +165,7 @@ Y1: $42,000.00 saved. $42,000.00 * 5% = $2,100.00 Total: $270.00 + $300.00 + $510.00 + $2,100.00 + $1,500.00 $4,680.00 - -Write a program to compute the total bonus amount earned by these two employees in the year. - -```ruby -class BonusOnSavings - def compute_bonus(commitment, q1, q2, q3, q4) - end -end -``` - -2. Description of the Code: - -[Briefly describe how you solved the problem in your code. You should include short description of classes, methods, and variables (if necessary) that you used in your code.] - -3. Errors and Warnings: - -[Please enlist your Errors and Warnings (maximum five) that you encountered in your code and how you solved them. An example of this is shown in Table 1.] -Table 1: List of Errors and Warnings Encountered in the Program - - -4. Sample Input and Output: -[Provide some test cases with sample input and output of your program.] - -5. Discussion: - -[In this section, you may include some discussion about the debugging strategy that you used, e.g., searched the Web for a solution, contacted tutor, solved by self, used a debugging tool, posted in forum, talked to a friend, etc.] +Then I started by writing tests to reproduce the expected results. Once +I had a working test, I began to implment the code to make the test +pass. After I got the tests passing I started to refactor the code by +extracting methods. |
