Refactor bank account and calculator code with improved comments and English translations

This commit is contained in:
vista-man
2025-01-27 20:14:28 +01:00
parent bbcbef3d2f
commit ef1b5f2420
3 changed files with 54 additions and 18 deletions

View File

@@ -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);
}
}