Тема: Потрібно перевести код Java на C#.
import java.util.Scanner;
public class Type2 {
public static void main(String[] args) {
double a, b, x, dx;
int choose;
Scanner in = new Scanner(System.in);
a = 0.5;
b = 4.5;
dx = 0.4;
while (true) {
System.out.print("Choose an action: \n" +
"1 - Calculate using a loop with a premise \n" +
"2 - Calculate using a loop with a postcondition \n" +
"3 - Exit the program \n" +
"Your answer: ");
choose = in.nextInt();
double y=0;
if (choose == 1) {
x = a;
System.out.printf("| x | y=f(x) |\n");
while (x <= b) {
System.out.printf("|%.3f | %.2f |\n", x, y);
x += dx;
y = Math.log(x);
}
}
if (choose == 2) {
x = a;
System.out.printf("| x | y=f(x) |\n");
do {
System.out.printf("|%.3f | %.2f |\n", x, y);
x += dx;
y = Math.log(x);
} while (x <= b);
}
if (choose == 3) {
break;
} else if (choose < 1 || choose > 3) {
continue;
}
}
}
}