diff options
| author | mokha <mokha@cisco.com> | 2019-05-13 21:49:39 -0600 |
|---|---|---|
| committer | mokha <mokha@cisco.com> | 2019-05-13 21:49:39 -0600 |
| commit | ef4b5233d2fbabf880e8944abfe79bd466a7e10f (patch) | |
| tree | 6f04f6d1676e11d20fd86628092cfa1505227882 /README.md | |
| parent | 3577d7930d626f55007ee02ca69331699c5bbc8d (diff) | |
update README
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 256 |
1 files changed, 27 insertions, 229 deletions
@@ -1,244 +1,42 @@ -Assignment 1 +Assignment #1 -1. Create a class named AddressBook that has the following field names: +Name: Mo Khan +Student ID: 3431709 -* firstName -* middleName -* lastName -* homeAddress -* businessPhone -* homePhone -* cellphone -* skypeId -* facebookId -* personalWebSite +This project uses `maven` as the primary build tool. `rake` is used as a +secondary build tool to drive the `mvn` goals. -Use appropriate data types to store the values for these fields in AddressBook objects. -Create appropriate get and set methods to retrieve and assign values to these names. -For example `getMiddleName(viveAddressBook)` should return the middle name of the person `Vive`. -Similarly, `vive.setPersonalWebsite(url)` should set the personal website of the person `Vive` to the specified URL object. -Using the get and set methods, create a comparison method `compareNames(name1, name2)` that compares the first, middle, and last names of strings name1 and name2. -Assume that name1 and name2 follow the following format: "FirstName M. LastName". +Instructions on how to install `maven` can be found [here](https://maven.apache.org/). -Test your program for correct, partially correct (e.g., name string without the middleName), -and incorrect inputs (e.g., phone number containing special characters). +To run the tests: - -2. Space Inc. will give a quarterly and annual bonus to its employees only if the savings of the quarter and/or -the year are greater than or equal to quarterly minimum (monthly commitment x 3) and/or the annual minimum (monthly commitment x 12) amount, respectively. - -The quarterly bonus is 3% of eligible quarterly savings, and the annual bonus is 5% of annual savings if eligible. -If the annual savings exceeds the committed amount by at least 25%, Space Inc. matches the additional savings (25% or above) as part of the annual bonus. - -I. An employee has committed to save $2000 per month. - -Her quarterly savings are as follows: - -Q1 – $5000 -Q2 – $7000 -Q3 – $4000 -Q4 – $8000 - -Quarterly minimum: $6,000 -Annual minimum: $24,000 - -Q1: Does not meet quarterly minimum. -Q2: Exceeds quarterly minimum. $7000 * 3% = $210 -Q3: Does not meet quarterly minimum -Q4: Exceeds quarterly minimum. $8000 * 3% = $240. -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: - -Q1 – $6000 -Q2 – $9000 -Q3 – $10000 -Q4 – $17000 - -Quarterly min: $9000.00 -Annual min: $36,000.00 - -Q1: does not meet quarterly min. -Q2: $9,000 * 3% = $270.00 -Q3: $10,000 * 3% = $300.00 -Q4: $17,000 * 3% = $510.00 -Y1: $42,000.00 saved. $42,000.00 * 5% = $2,100.00 - -42,000 - 36,000 = $6,000 * 25% = $1,500.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 +```bash + $ mvn test ``` -3. Write a program that prompts the user to enter two points `(x1, y1)` and `(x2, y2)`. -Calculate and display the distance between the two points using the formula below. -Round the answer up to 2 decimal points. -You can use `Math.pow(a,0.5)` to compute the square root of an expression. -`Math.pow()` returns a double. - -For example, the distance between the points (−2, −3) and (−4, 4) is approximately 7.28, as shown below. - -4. A group of AU friends decide to run the Banff, Alberta, Marathon. -Their names, times (marathon completion time in minutes), and number of years participated are given below: - -| id | Name | time (mins) | years | -| --- | --- | --- | --- | -| 1 | Elena Brandon | 341 | 1 | -| 2 | Thomas Molson | 273 | 2 | -| 3 | Hamilton Winn | 278 | 5 | -| 4 | Suzie Sarandin | 329 | 7 | -| 5 | Philip Winne | 445 | 9 | -| 6 | Alex Trebok | 275 | 3 | -| 7 | Emma Pivoto | 275 | 4 | -| 8 | John Lenthen | 243 | 1 | -| 9 | James Lean | 334 | 1 | -| 10 | Jane Ostin | 412 | 1 | -| 11 | Emily Car | 393 | 4 | -| 12 | Daniel Hamshire | 299 | 4 | -| 13 | Neda Bazdar | 343 | 3 | -| 14 | Aaron Smith | 317 | 6 | -| 15 | Kate Hen | 265 | 8| - -Extend the AddressBook class from Problem 1 to store the additional data. -Now, write a method to find the fastest runner. -Print the name, address, and his/her time (in minutes) on three separate lines. -Find the second fastest runner. -Print the name, address, his/her time (in minutes), and the difference in time with the fastest runner. -Compute the average time of completion taken by these runners. -Finally, print the name and number of years participated for each runner if the runner’s time of completion is equal to or better than the average time of completion. - -5. Solve the following problem using a program: -Suppose you save $100 each month into a savings account with an annual interest rate of 5%. -Thus, the monthly interest rate is 0.05/12 = 0.00417. -After the first month, the value in the account becomes 100 * (1 + 0.00417) = 100.417 -After the second month, the value in the account becomes (100 + 100.417) * (1 + 0.00417) = 201.252 -And after the third month, the value in the account becomes (100 + 201.252) * (1 + 0.00417) = 302.507 -... and so on. +To run the console application: -Write a program that randomly generates monthly savings amounts for the 15 runners in Problem 4. -Each monthly saving should be in the range of $100 to $800. -Extend the AddressBook class to store the monthly savings generated by the random number generator. -Then, display the final account value for each of the 15 runners. - - -6. "The Pythagorean Theorem relates the lengths of the three sides of any right triangle. -The legs of a right triangle (the two sides of the triangle that meet at the right angle) -are customarily labelled as having lengths "a" and "b", and the hypotenuse -(the long side of the triangle, opposite the right angle) is labelled as having length "c". -The lengths are related by the following equation: a^2 + b^2 = c^2." -– http://www.purplemath.com/modules/pythagthm.htm - -This equation allows you to find the length of a side of a right triangle when they’ve given you the lengths for the other two sides, -and, going in the other direction, allows you to determine if a triangle is a right triangle when they’ve given you the lengths for all three sides. -This equation can alternatively be written as c = sqrt of (a^2+b^2). -You can find the square root of a number by calling the standard function Math.sqrt. - -For example, the statement `double y = Math.sqrt(x)` sets `y` to the square root of `x`. - -I. Given the right triangles described below, write a program to compute the lengths of the remaining sides using a program. -a. a=48, c=80 b = 64 -b. a=84, c=91 b = 35 - -```text - a^2 + b^2 = c^2 - b^2 = c^2 - a^2 - b = sqrt(c^2 - a^2) +```bash + $ mvn package + $ java -cp target/assignment1*.jar ca.mokhan.comp268.App ``` -II. Determine if the following triangles are right-angled triangles: -a. a=45, b=55, c=75 -b. a=28, b=45, c=53 - -7. Douglas Hofstadter’s Pulitzer-prize-winning book Gödel, Escher, Bach contains many interesting mathematical puzzles. - -In Chapter XII, Hofstadter mentions a wonderful problem that is well within the scope of the control statements in Java. - -The problem can be expressed as follows: - -* Pick some positive integer and call it n. -* If n is even, divide it by two. -* If n is odd, multiply it by three and add one. -Continue this process until n is equal to 1. - -Hofstadter illustrates this process with the following example, -starting with the number n = 15: -15 is odd, so I make 3n+1: 46 -46 is even, so I take half: 23 -23 is odd, so I make 3n+1: 70 -70 is even, so I take half: 35 -35 is odd, so I make 3n+1: 106 -106 is even, so I take half: 53 -53 is odd, so I make 3n+1: 160 -160 is even, so I take half: 80 -80 is even, so I take half: 40 -40 is even, so I take half: 20 -20 is even, so I take half: 10 -10 is even, so I take half: 5 -5 is odd, so I make 3n+1: 16 -16 is even, so I take half: 8 -8 is even, so I take half: 4 -4 is even, so I take half: 2 -2 is even, so I take half: 1 +To generate the javadoc documentation: -As you can see from this example, the numbers go up and down, but eventually—at least for all numbers that have ever been tried—come down to end in 1. -In some respects, this process is reminiscent of the formation of hailstones, -which get carried upward by the winds over and over again before they finally descend to the ground. -Because of this analogy, this sequence of numbers is usually called the Hailstone sequence, -although it goes by many other names as well. -Write a program that reads in a number from the user and then displays the Hailstone sequence for that number, -followed by a line showing the number of steps taken to reach 1. - -8. Google Inc. is looking to recruit three of the Boston runners. - -The criteria for selection are as follows: - -* I. Average final marks in bachelor’s degree (store up to 2 decimal places). - The fifteen candidates have the following grades: 82.30%, 85.10%, 77.77%, 69.93%, 93.03%, 88.61%, 55.99%, 87.49%, 88.00%, 91.20%, 66.79%, 76.65%, 55.89%, 90.01%, and 87.9%. -* II. Ability to communicate as one of the three values – "excellent", "average", and "poor". - The fifteen candidates have the following ability to communicate, respectively: poor, poor, average, average, average, poor, excellent, excellent, excellent, average, excellent, average, excellent, excellent, poor. -* III. Innovation as one of the two values – "brilliant" and "average" (store as a Boolean; brilliant = true and average = false). - The fifteen candidates have the following innovative abilities: brilliant, average, average, average, brilliant, brilliant, average, brilliant, average, brilliant, average, brilliant, brilliant, average, average. -* IV. Ability to regulate one’s own skill as a probability value between 0 and 1.0 – 1.0 implies excellent regulatory capabilities and 0.0 implies no skills to regulate (store as a double). - The fifteen candidates have the following regulatory abilities: 0.5, 1.0, 0.8, 0.0, 1.0, 0.7, 0.8, 0.9, 0.5, 0.6, 0.3, 0.2, 0.5, 0.3, 0.8. - -Store these values for the fifteen candidates in an extended AddressBook class. - -In general, Google will not consider a candidate with average marks of less than 85%. - -Google will consider a candidate with average marks of less than 85% only if the candidate at least has 0.5 regulatory abilities and at least 'average' ability to communicate. - -Google will only consider a candidate with poor communication ability if the candidate has a 'brilliant' innovation capability. - -Write a program that will help Google to programmatically determine eligibility of the fifteen candidates for these positions, and print the output on the console. - -9. Write a program that iterates through numbers from 0 to 113 using a loop. -Print the numbers, one number per line. -As you print each number, say x, also print the following when appropriate, separated by commas: - -If the number is odd, print “x is odd” -If the number is divisible by 5, print “hi five” -If the total of a number (x) and its subsequent number (x+1) is a value divisible by 7, print “wow” -If the number is prime, print “prime”. +```bash + $ mvn javadoc:javadoc +``` -10. Modify the following program to the specifications given below: +This project attempts to adhere to the project structure guidelines +described in `doc/Comp268_requirements_2017.pdf`. To accomplish this +some customization had to be made to the maven configuration on +`pom.xml`. -* Add a new status – - SingleParent – where the tax is computed as a SINGLE but with a further reduction of $5000 per child. -* Add a new tax condition – - if the income is greater than $249,999 for SINGLE, then add a tax of 25% on income amount above $150,000; - if the income is greater than $349,999 for MARRIED, then add a tax of 35% on income amount above $200,000. +The accompanying `Rakefile` includes a `package` task that takes the +source and bundles a zip using the project structure guidelines +described in `doc/Comp268_requirements_2017.pdf`. -Unknown status – if the status doesn’t belong to SINGLE or MARRIED or SINGLE_PARENT, then compute a 33% tax on the income. +It is highly suggested to use `mvn` from the root of this source tree +rather than using the bundled package with the non-standard source +layout. |
