Challenge: Commission Calculator
You are developing a program for a bank that needs to calculate commission based on the transaction type. Your task is to write a switch
statement that will output the commission based on the type of incoming transaction.
Commission rates based on transaction type:
Payment
: 0.5%;Transfer
: 1.2%;Withdrawal
: 2.0%;Deposit
: 0.0% (no commission).
Replace ___
with the necessary code to compile it. Don't hesitate to check the hint and solution to understand the task better.
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
let transactionType: string = "Transfer"; // You can change the operation type
let commission: number;
switch (transactionType) {
case ___:
___ = 0.5;
break;
case ___:
___ = ___;
break;
case ___:
___ = ___;
break;
case ___:
___ = ___;
break;
___:
___ = -1; // Handle unknown transaction types
}
console.log(`Commission for ${transactionType}: ${commission}%`);
123456789101112131415161718192021let transactionType: string = "Transfer"; // You can change the operation type let commission: number; switch (transactionType) { case ___: ___ = 0.5; break; case ___: ___ = ___; break; case ___: ___ = ___; break; case ___: ___ = ___; break; ___: ___ = -1; // Handle unknown transaction types } console.log(`Commission for ${transactionType}: ${commission}%`);
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 2. Capítulo 7
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo