You are strongly encouraged to submit your work regularly (how to submit your work can be found at the bottom of this page).
Start Android Studio. Open the FinalB project. The project contains the package eecs1022.finalb. The package contains the classes Question1, Question2, ..., Question7. If you cannot find these classes, please let the teaching assistant know.
Question | Marks | Partial marks? |
---|---|---|
1 | 10 | yes |
2 | 5 | yes |
3 | 5 | yes |
4 | 2.5 | no |
5 | 2.5 | no |
6 | 2.5 | no |
7 | 2.5 | no |
Implement the class Badge. Its API can be found here. The API of the Date class can be found here
The class Question 2
contains the method
/** * Returns the value of 1 * 2 * ... * n. You have to use a loop to solve this question. * You may assume that n is greater than 0. * * @param n a positive integer. * @return the value of 1 * 2 * ... * n */ public static int product(int n) { }Implement this method using a loop. Below you find some sample inputs and outputs.
Input Argument |
Output Return |
---|---|
1 | 1 |
2 | 2 |
3 | 6 |
4 | 24 |
5 | 120 |
The class Question 3
contains the method
/** * Print the following pattern of the given length. You may assume that the given length * is greater than or equal to 0. * The pattern is: *+**+++****... * * @param length the length of string to be printed. */ public static void pattern(int length) { }Implement this method. Below you find some sample inputs and outputs.
Input Argument |
Output Return |
---|---|
1 | * |
4 | *+** |
9 | *+**+++** |
11 | *+**+++**** |
34 | *+**+++****+++++******+++++++***** |
The class Question 4
contains the method
/** * Prints N of the given height. You may assume that the height is at least 3. * See test for sample outputs. * * @param height the height of the N. */ public static void n(int height) { }Implement this method. Below you find some sample inputs and outputs.
Input Argument |
Output Return |
---|---|
3 |
* * *** * * |
4 |
* * ** * * ** * * |
5 |
* * ** * * * * * ** * * |
6 |
* * ** * * * * * * * * ** * * |
7 |
* * ** * * * * * * * * * * * ** * * |
The class Question 5
contains the method
/** * Tests whether the given string contains all ten digits, that is, whether it contains * 0, 1, ..., and 9. You may assume that the string is not null. * * @param s a string. * @return true if the given string contains all ten digits, false otherwise. */ public static boolean containsAll(String s) { }Implement this method. Below you find some sample inputs and outputs.
Input Argument |
Output Return |
---|---|
0123456789 | true |
9876543210 | true |
a9b0c8d1e7f2g6h3i5j4k | true |
abcdefgh | false |
123456789 | false |
The class Question 6
contains the method
/** * Returns the average of the digits occurring in the given string. You may assume that * the string is not null and contains at least one digit. * * @param s a string. * @return the average of the digits occurring in the given string. */ public static double average(String s) { }Implement this method. Below you find some sample inputs and outputs.
Input Argument |
Output Return |
---|---|
1234 | 2.5 |
1a5h5x1 | 3.0 |
12h56s9 | 4.6 |
aaaaaa4aaaaa | 4.0 |
5a | 5.0 |
The class Question 7
contains the method
/** * Returns the number of characters that occur more than once in the given string. * You may assume that the string is not null and not empty. You may may also assume * that all characters are lower case letters. * * @param s a string. * @return the number of characters that occur more than once in the given string. */ public static int moreThanOnce(String s) { }Implement this method. Below you find some sample inputs and outputs.
Input Argument |
Output Return |
---|---|
a | 0 |
accb | 1 |
abacb | 2 |
abca | 1 |
aaabbcc | 3 |
Before 19:45, submit your code as follows.
You can repeat the above steps as many times as you like throughout the test. Every submission overwrites the previous one. Submission of a file does not imply that you cannot continue to work on the file and resubmit it.
If you submit after 19:45 but before 19:50, you will get a penalty of 1 mark per minute (the test is worth 30 marks).