GithubHelp home page GithubHelp logo

hw_week1_day3_functions's Introduction

HW_week1_Day3_Functions ๐Ÿ˜ƒ


The Home Work has three components to be delievered before 9AM: โš ๏ธ

  • Part I: Practice with functions.
  • Part II: Practice with Anonymous Functions.
  • Part III: More Practicing (Optional).

Note: You must save your solution as solution_part1.kt for Part I, and solution_part2.kt for Part II to be submitted before 9AM. โš ๏ธ

Instructions ๐Ÿ“‹


We'll be working through problems designed to get more practice with the concepts covered during the previous lesson (Variables, Conditionals).

Part I - Practice with functions.


Question 1

Create a function called add() that takes two input numbers and returns the sum of these numbers.

fun main() {
   println(add(10,12))
}
Output: 22

Question 2

Create a function called fullName() that takes three inputs strings which are first, middle, and last name, and returns the full name.

fun main() {
   println(fullName("Ahmed","Abdullah","Al Waleed"))
}
Output: "Ahmed Abdullah Al Waleed"

Part II - Practice with Anonymous Functions.


Question 3

Create an anonymous function called maximum() that takes three number as input and return the largest one of these numbers.

fun main() {
    println(maximum(10,14,12))
}

Output: "The largest number is 14"

Part III - More Practicing (Optional).


Challenge 1: Mathematical Operations

Create a function called math() that takes two input numbers and that will do Add, Subtract, Multiply, and Divide between these two numbers, and return the operator's name with its result.

fun main() {
   println(math(2,3))
}
Output: 
        Add: 5
        Subtract: -1
        Multiply: 6
        Divide: 0 

Challenge 2: Fireball Fuel Level

Casting fireballs does not just print a message to the console. While NyetHack fireballs are strong, the player should not be able to cast an unlimited amount of them. Make the castFireball() function return a resulting remaining fuel value that depends on the number of fireballs cast. The fuel value should be between 1 and 50, with 50 being the maximum amount of fuel in the game.

Learning Resources ๐Ÿ“š

hw_week1_day3_functions's People

Contributors

mohamedfouad96 avatar joud-almahdi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.