What code have I to write for this logic?

I am trying to create an app that is gonna be some type of finical application. Suppose you go on a picnic, you paid for food, your friend paid for parking and your another friend paid for rides. Now when you return, you want everyone to pay the same amout of money. How you will do that, you will count the number of friends, sum of money they paid together, and then divide it with the number of friends, the result is gonna be the answer. So that’s what I wanna do.

So the logic of the app will be:-
Ask for number of friends and the money each paid, then finally divide the sum of money with the number of friends.

So how will I write the program/block for this logic. Remember the number of friend is dynamic, one may enter 5 another may enter 10. So please help me with this.

Basic Exercise, Algorithm Lesson 2…
Accumulate values in 1 variable…
variable = variable + value…
Divide variable by the number of people…
parcel = variable / number of people…

1 Like

I figured it out. Today I was learning about arrays and then tried to write a program based on this logic and it even works. Here’s what I wrote: Expense Tracker – Google Drive

Basic programming logic exercises ( C language ). But this is a Kodular community.

Yes I know it’s C, well, the thing is since I am learning C, I use to try all my logic building there. Since I am done with the logic, I will get my app done in Kodular.

1 Like

1- Start searching now about: how to record and get values ​​from Tinydb.
2 - you will need a variable to accumulate the spent amounts : search about , variables and accumulators
3 - you will need to get the number of friends: search on text box and the TEXT property (This is where the number of friends will be taken and used in the formula - I already showed the formula here in this post)
4- Use the formula and display the result in a Component label or Textbox

1 Like

Thank you very much!

1 Like