GoConqr has a new look! Let us know what you think.

Module 14 of 16 · Media

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.

 

 

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?