mirror of
https://github.com/Alvin-Zilverstand/ict-algemeen-opdrachten.git
synced 2026-03-06 13:23:58 +01:00
Refactor bank account and calculator code with improved comments and English translations
This commit is contained in:
@@ -4,17 +4,21 @@ class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// Ask the user to enter the first number
|
||||
Console.WriteLine("Enter the first number:");
|
||||
double num1 = Convert.ToDouble(Console.ReadLine());
|
||||
|
||||
// Ask the user to enter an operator (+, -, *, /)
|
||||
Console.WriteLine("Enter an operator (+, -, *, /):");
|
||||
string op = Console.ReadLine();
|
||||
|
||||
// Ask the user to enter the second number
|
||||
Console.WriteLine("Enter the second number:");
|
||||
double num2 = Convert.ToDouble(Console.ReadLine());
|
||||
|
||||
double result = 0;
|
||||
|
||||
// Perform the operation based on the entered operator
|
||||
switch (op)
|
||||
{
|
||||
case "+":
|
||||
@@ -33,15 +37,18 @@ class Program
|
||||
}
|
||||
else
|
||||
{
|
||||
// Display an error message if attempting to divide by zero
|
||||
Console.WriteLine("Cannot divide by zero.");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Display an error message if the entered operator is invalid
|
||||
Console.WriteLine("Invalid operator.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Display the result of the calculation
|
||||
Console.WriteLine("The result is: " + result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user