I need some tips with my homework. I would appreciate any tips.
The objective is to create a two dimensional array where column 1 is the segment ID and column 2 is the segment value. 6 segments. User will be asked to enter each value for each ID.
[ 0 3
1 2
2 1
3 5
4 2
5 3 ]
User will enter any 3 ID’s: e.g. 012 and each corresponding value will be added to the next.
So 035 would equal 3+5+3 = 11.
What would be a good way to go about this, and what loop would best suit this?
I understand how arrays work but I’m struggling to wrap my head around this problem.
I don’t think any loops are necessarily involved and the array doens’t need to be two-dimensional. I’m assuming that the user choices correspond to the indices of the array (e.g. 0 – 6). Once you get the three inputs from the user, you can just reference the array elements directly. For example: