Code Lab

Modo entrevista. Cronômetro de 10 min, sem dicas e sem autocompletar

Total price of pies

FácilBasics10 min

Write a function piesPrice(dollars, cents, count) that finds how much count pies cost. One pie costs dollars dollars and cents cents. 1 dollar is 100 cents.

  • All three parameters are integers: dollars and count are 0 or more, cents is from 0 to 99.
  • Return an array of two integers: [totalDollars, totalCents].
  • totalCents is from 0 to 99: every 100 cents make one more dollar. 3 pies at 2 dollars 50 cents cost 7 dollars 50 cents, so the answer is [7, 50], not [6, 150].
  • If count is 0, the pies cost nothing: return [0, 0].

Exemplos

piesPrice(2, 50, 3)

Retorna [ 7, 50 ]

3 pies at 2 dollars 50 cents: 750 cents, that is 7 dollars 50 cents.
piesPrice(10, 15, 2)

Retorna [ 20, 30 ]

Cobrada em T-Bank · Fonte

Carregando o editor...
  1. EntradapiesPrice(2, 50, 3)
    Esperado[ 7, 50 ]
  2. EntradapiesPrice(10, 15, 2)
    Esperado[ 20, 30 ]
  3. EntradapiesPrice(2, 5, 2)
    Esperado[ 4, 10 ]
  4. EntradapiesPrice(5, 20, 0)
    Esperado[ 0, 0 ]

Os testes ocultos rodam no envio