One line of a receipt

Read one item from a shop and print its line on the receipt.

What to build

A program that reads three lines, works out a total and prints a receipt line.

Requirements

  • Read the item's name, then its price, then the quantity.
  • Print QUANTITY x NAME = TOTAL.
  • Print Thank you! on the next line.

Input

Three lines: the name, the price (a whole number), the quantity (a whole number).

Output

Two lines.

Constraints

The price is from 1 to 100000, and the quantity is from 0 to 1000. The name may contain spaces.

Example

Input:

Pen
10
3

Output:

3 x Pen = 30
Thank you!

Why it works

Each prompt() takes the next line, so the order of the calls matches the order of the input. The total is a calculation, so it needs real numbers, while the name stays text.

Examples

Example 1 · Input
Pen
10
3
Expected output
3 x Pen = 30
Thank you!
Example 2 · Input
Notebook
60
1
Expected output
1 x Notebook = 60
Thank you!

Hints

Hint 1

Call prompt() three times, once for each line of input.

Hint 2

Convert the price and the quantity with Number before you multiply them.

Hint 3

A template string can hold a calculation: ${price * quantity}.

Solution

Show one correct solution (try it yourself first)
const item = prompt();
const price = Number(prompt());
const quantity = Number(prompt());
console.log(`${quantity} x ${item} = ${price * quantity}`);
console.log("Thank you!");

Lesson: JavaScript and the web →