title | type | duration | creator | ||||
---|---|---|---|---|---|---|---|
Writing Advanced Functions |
Lab |
1:25 |
|
Note: You can help each other, but everyone must turn in their own code
You are supposed to write 10 functions that accept parameters. You can use control flow and multiple conditionals. When a function is created, please call it (from inside the main
method) and test all the cases including edge cases (e.g. empty strings, null values, extremely big and small values). It is of high importance to practice and master Java fundamentals, which are the core of Android development. Java functions create the solid foundation, without which it is impossible to build high quality bug free apps.
- Fork this repository & clone your fork to your computer
- Inside the repo folder create a new IntelliJ project
- Add code to the IntelliJ project to complete the requirements
- Commit your changes & push them up to Github
- Submit a pull request and put your name and "Functions Advanced Lab" in the pull request title
-
Write a function that takes in a number and returns true if the number is even or false if the number is odd. You may use control flow and multiple conditionals.
-
Write a function that takes in two words and compares them. If the spelling is the same, the functions returns true, otherwise false.
-
Write a function that takes in a word and prints out its every letter on a new line before it sees the letter "w". If it encounters "w" the function should stop executing.
-
Write a function that generates a random number. Print it out. If the number is greater that 50, return it, otherwise return -1. You may use control flow and multiple conditionals.
-
Write a function that takes in 3 integers: day, month, and year and computes day, month, and year of the next day. The function should return a string (e.g. day:12 month:11 year:1988)
-
Write a function that takes in a word, omits every other letter in that word and returns a new word. You can use control flow and multiple conditionals.
-
Write a function that takes in a number greater than 5 and prints out all the numbers from 1 to that number except number 4. Please use a while statement.
-
Write a function that takes in 2 numbers, and checks if they are the same. If they are not the same, it adds 1 to every number and returns its sum. If the numbers are the same, it adds 2 to every number and returns its sum.
-
Write a function that asks the user to enter a country domain. If the user types in "us", the function prints out "United States", if the user enters "de", the function prints out "Germany", if the user types in "hu" the response should be "Hungary". In all other cases the function should print out "Unknown". Please try to use a switch statement and make sure the function works with a user's input of lower and upper case strings.
-
Write a function that asks the user to type in a letter and prints out whether the letter is a vowel or a consonant. You may use control flow and multiple conditionals.
You are expected to create one Java file with 10 functions and a main
method that calls all the other functions, testing all cases. This file should be in an IntelliJ project, and you should submit it via pull request.