-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1038.js
31 lines (22 loc) · 821 Bytes
/
1038.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Input
// The input file contains two integer numbers X and Y. X is the product code and Y is the quantity of this item according to the above table.
// Output
// The output must be a message "Total: R$ " followed by the total value to be paid, with 2 digits after the decimal point.
const productCode = 3;
const quantity = 2;
if (productCode === 1) {
console.log(quantity * 4);
} else if (productCode === 2) {
console.log(quantity * 4.5);
} else if (productCode === 3) {
console.log(quantity * 5);
} else if (productCode === 4) {
console.log(quantity * 2);
} else if (productCode === 5) {
console.log(quantity * 1.5);
}
//// 2nd way ////
const priceList = [4.00, 4.50, 5.00, 2.00, 1.50];
// Calculate the total price
const totalPrice = priceList[productCode - 1] * quantity
console.log(totalPrice);