diff options
| author | mokha <mokha@cisco.com> | 2019-05-08 19:20:31 -0600 |
|---|---|---|
| committer | mokha <mokha@cisco.com> | 2019-05-08 19:20:31 -0600 |
| commit | 45cc3ed51321f3a735ceed7e3394ee3e6ab16af1 (patch) | |
| tree | cee4e78bc52a57e51a448ac237c372397ca38f46 | |
| parent | 24f849e76ac46ef2a08c3904cecb195e4f7f85af (diff) | |
start program profile for each question
| -rw-r--r-- | src/Q10/README.md | 32 | ||||
| -rw-r--r-- | src/Q2/README.md | 81 | ||||
| -rw-r--r-- | src/Q3/README.md | 31 | ||||
| -rw-r--r-- | src/Q4/README.md | 52 | ||||
| -rw-r--r-- | src/Q5/README.md | 37 | ||||
| -rw-r--r-- | src/Q6/README.md | 51 | ||||
| -rw-r--r-- | src/Q7/README.md | 64 | ||||
| -rw-r--r-- | src/Q8/README.md | 46 | ||||
| -rw-r--r-- | src/Q9/README.md | 32 |
9 files changed, 426 insertions, 0 deletions
diff --git a/src/Q10/README.md b/src/Q10/README.md new file mode 100644 index 0000000..3aeaa08 --- /dev/null +++ b/src/Q10/README.md @@ -0,0 +1,32 @@ +Learning Profile for Assignment #1, And Question #10 + +Name: Mo Khan +Student ID: 3431709 + +1. Problem Statement: +Modify the following program to the specifications given below: + +* 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. + +Unknown status – if the status doesn’t belong to SINGLE or MARRIED or SINGLE_PARENT, then compute a 33% tax on the income. + +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.] diff --git a/src/Q2/README.md b/src/Q2/README.md new file mode 100644 index 0000000..2335548 --- /dev/null +++ b/src/Q2/README.md @@ -0,0 +1,81 @@ +Learning Profile for Assignment #1, And Question #2 + +Name: Mo Khan +Student ID: 3431709 + +1. Problem Statement: + +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 +``` + +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.] diff --git a/src/Q3/README.md b/src/Q3/README.md new file mode 100644 index 0000000..8c880cb --- /dev/null +++ b/src/Q3/README.md @@ -0,0 +1,31 @@ +Learning Profile for Assignment #1, And Question #3 + +Name: Mo Khan +Student ID: 3431709 + +1. Problem Statement: + +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. + +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.] diff --git a/src/Q4/README.md b/src/Q4/README.md new file mode 100644 index 0000000..f3e1359 --- /dev/null +++ b/src/Q4/README.md @@ -0,0 +1,52 @@ +Learning Profile for Assignment #1, And Question #4 + +Name: Mo Khan +Student ID: 3431709 + +1. Problem Statement: + +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. + +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.] diff --git a/src/Q5/README.md b/src/Q5/README.md new file mode 100644 index 0000000..444a28f --- /dev/null +++ b/src/Q5/README.md @@ -0,0 +1,37 @@ +Learning Profile for Assignment #1, And Question #5 + +Name: Mo Khan +Student ID: 3431709 + +1. Problem Statement: + +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. + +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. + + +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.] diff --git a/src/Q6/README.md b/src/Q6/README.md new file mode 100644 index 0000000..5c076e9 --- /dev/null +++ b/src/Q6/README.md @@ -0,0 +1,51 @@ +Learning Profile for Assignment #1, And Question #6 + +Name: Mo Khan +Student ID: 3431709 + +1. Problem Statement: + +"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) +``` + +II. Determine if the following triangles are right-angled triangles: +a. a=45, b=55, c=75 +b. a=28, b=45, c=53 + +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.] diff --git a/src/Q7/README.md b/src/Q7/README.md new file mode 100644 index 0000000..8f79356 --- /dev/null +++ b/src/Q7/README.md @@ -0,0 +1,64 @@ +Learning Profile for Assignment #1, And Question #7 + +Name: Mo Khan +Student ID: 3431709 + +1. Problem Statement: + +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 + +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. + + +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.] diff --git a/src/Q8/README.md b/src/Q8/README.md new file mode 100644 index 0000000..41d24cd --- /dev/null +++ b/src/Q8/README.md @@ -0,0 +1,46 @@ +Learning Profile for Assignment #1, And Question #8 + +Name: Mo Khan +Student ID: 3431709 + +1. Problem Statement: + +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. + +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.] diff --git a/src/Q9/README.md b/src/Q9/README.md new file mode 100644 index 0000000..c835bc9 --- /dev/null +++ b/src/Q9/README.md @@ -0,0 +1,32 @@ +Learning Profile for Assignment #1, And Question #9 + +Name: Mo Khan +Student ID: 3431709 + +1. Problem Statement: + +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”. + +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.] |
