セクション 1. 章 9
single
Challenge: Math Operation Handler
メニューを表示するにはスワイプしてください
タスク
スワイプしてコーディングを開始
You're building a simple math operation processor that performs different calculations based on the selected operation type.
Use a switch statement to handle each operation type.
- Addition (
case 1)- Add
aandb.
- Add
- Subtraction (
case 2)- Subtract
bfroma.
- Subtract
- Multiplication (
case 3)- Multiply
abyb.
- Multiply
- Division (
case 4)- Check if
bis not equal to zero. - If true, divide
abyb. - Otherwise, print
"Error: Division by zero"and return0.
- Check if
- Default Case
- Print
"Invalid operation type"if the number doesn't match any valid case.
- Print
- Return the result of the performed operation.
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 1. 章 9
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください