Created
November 17, 2023 12:49
-
-
Save NonymousMorlock/a8795d43167f80db0d50ab902c0647e0 to your computer and use it in GitHub Desktop.
Solution to the conversion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void greeting(String name) { | |
| print('Hello $name!!!'); | |
| } | |
| int sum(int firstNumber, int secondNumber) { | |
| return firstNumber + secondNumber; | |
| } | |
| void difference(int n1, int n2) { | |
| print('The difference between $n1 & $n2 is ${n1 - n2}'); | |
| } | |
| List allNames(String firstName, String secondName, String thirdName, | |
| String fourthName, String fifthName) { | |
| return [firstName, secondName, thirdName, fourthName, fifthName]; | |
| } | |
| // notice how this returns double, why? because the quotient is a result from division, | |
| // and two numbers dividing could easily result in a fraction, and a fraction is essentially | |
| // a decimal pointed number when converted to a number | |
| double sumOfProductAndQuotient(int firstNumber, int secondNumber) { | |
| int product = firstNumber + secondNumber; | |
| double quotient = firstNumber / secondNumber; | |
| double resultingSum = product + quotient; | |
| return resultingSum; | |
| } | |
| greeting('Louis'); | |
| int ourSum = sum(1, 2); | |
| print(ourSum); | |
| difference(2, 1); | |
| List students = allNames('Louis', 'Paul', 'Joy', 'Michael', 'Gideon'); | |
| print(students); | |
| double resultSum = sumOfProductAndQuotient(2, 3); | |
| print(resultSum); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment