nus-cs2113-AY2223S2 / forum

10 stars 0 forks source link

💡 Coursemology Week 3 Question 10: Ex10 #9

Open choongzhanhong opened 1 year ago

choongzhanhong commented 1 year ago

Hi folks, this was originally supposed to be a help request for Ex10, but I found the solution while writing this, so I'm sharing with the rest of you.

Note that the desired output is this: Your expenses while overseas?Expenses in overseas currency:[$4.50, $3.00, $5.00] Total in local currency: $21.25

The skeleton code does not use println but instead uses print (Does not automatically go to a newline). Also note there is no space between "Expenses in overseas currency:" and your array. These have to match the output on Coursemology to be considered correct.

Honestly, the desired output is not very nice because of inconsistent spacing, but oh well. Coursemology asks, I give.

lihka1202 commented 1 year ago

Yep, aside from the spacing and println vs print, the other important thing is to format the final line properly. Just using .toString would yield 0.0 if the sum is 0, however coursemology requires the output to be 0.00.

okkhoy commented 1 year ago

Errm.. thanks for pointing it out. Let me get some of these fixed. print vs println was a conscious choice due to some Coursemology limitations.