GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Modul 14 von 16 · Medien

Rest of the week

Kostas Diakogiannis

Rest of the week

F-8 Money until rest of the week calculator

Write a function that calculates how much money someone is going to earn until the end of the week by just accepting a number from 1 to 7 that represents the days of the week. (1 is for Monday, 2 for Tuesday, etc 7 is for Sunday).

Given someone earns 10$ per hour and his working schedule is this:

Monday: works 4 hours

Tuesday:  works 6 hours

Wednesday:  works 8 hours

Thursday: works 10 hours 

Saturday: works 2 hours

Fridays and Sundays  can have his days-off.

 

For example: if we execute calculateRestOfWeekMoney(3) The number 3 is passed as argument indicates that today is Wednesday so we calculate from Wednesday (included) until sunday.

With calculateRestOfWeekMoney(4) we start counting from thursday until sunday etc.

 

Rules: Write this in a re-usable way and without using a loop (recursive style maybe!).

Estimated time: 30 mins.

 

 

Anleitung

Um im Kurs weiterzukommen, sende einen Versuch dieses Quiz ab. Du kannst ihn nach der letzten Frage absenden.

Zum gewählten Modul

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck