EasyBasicsNot started

Cafe bill total

A cafe till exports three order lines. Each line contains a decimal price followed by an integer quantity. Calculate the combined bill and print it with exactly two digits after the decimal point.

Input

Three lines, each containing a price and quantity separated by one space.

Output

One line: the bill total formatted to two decimal places.

Example 1

Input

3.50 2
2.25 1
1.00 3

Output

12.25

7.00 + 2.25 + 3.00 gives 12.25.

Constraints

  • 0.01 <= price <= 1000
  • 1 <= quantity <= 100

Hints

Hint 1 of 3

Map Number over the split input fields.

Hint 2 of 3

Add price * quantity inside the loop.

Hint 3 of 3

toFixed(2) supplies the required two decimal places.

Solution

Show a reference solution and explanation
 JavaScript · reference solution
let total = 0;
for (let i = 0; i < 3; i++) {
  const [price, quantity] = readline().split(' ').map(Number);
  total += price * quantity;
}
console.log(total.toFixed(2));

Why it works

Each input line becomes two numbers through destructuring. The loop accumulates their product, and toFixed(2) turns the final number into the exact display format requested by the till.

Lesson for this exercise: JavaScript Operators: Arithmetic, Comparison and Logic

Your program
let total = 0;
for (let i = 0; i < 3; i++) {
  const [price, quantity] = readline().split(' ').map(Number);
  // add this line's value
}
console.log(total.toFixed(2));

Tests: 3 cases including the examples. Passing every test marks the exercise solved in this browser.

How this page was checked. Every program on it was run with Node.js 22 at build time; runs in your browser in an isolated Web Worker by the publishing checks, and the output shown is what it printed. The Run buttons execute the same code on your device; nothing you type is sent anywhere.