For цикл-ввод с тастатуры или как это сделать?

Привет ,помогите решить уровнения Math.sqrt(x+1)?Math.sqrt(1-2*Math.sin(x)) в Java используя цикл for

double x, dx, xg;

Scanner sc = new Scanner(System.in);


System.out.println("from: ");
if (sc.hasNextDouble())
x = sc.nextDouble();
else {
System.out.println("input error");
sc.close();

return;
}

System.out.println("to: ");
if (sc.hasNextDouble())
xg = sc.nextDouble();
else {
System.out.println("input error");
sc.close();
return;
}

System.out.println("step: ");
if (sc.hasNextDouble())
dx = sc.nextDouble();
else {
System.out.println("input error");
sc.close();
return;
}
sc.close();


System.out.println("x-------F");

for (;x<=xg;) {
if (x<-1 || 2*Math.sin(x)>0 ||
Math.abs(1-2*Math.sin(x))<0.0001)
System.out.println(x + " not defined");
else
System.out.println(x + " " +
Math.sqrt(1+x)/Math.sqrt(1-2*Math.sin(x)));
x=x+dx;

}
  • Вопрос задан
  • 57 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
Bell Integrator Ульяновск
До 400 000 ₽
Bell Integrator Хабаровск
До 400 000 ₽
Bell Integrator Ижевск
До 400 000 ₽
19 апр. 2024, в 14:12
30000 руб./за проект
19 апр. 2024, в 14:10
500 руб./за проект