Answer the question
In order to leave comments, you need to log in
Error: The method nextInt() is undefined for the type java.io.Reader?
I'm new to
writing a program.
Finished, I click compilation and then Error: The method nextInt() is undefined for the type java.io.Reader
here is the program.
help me please
import java.lang.*;
import java.io.Reader;
import java.util.Scanner;
public class karlic20
{
Scanner sc = new Scanner(System.in);
public static void main(String[]args)
{
System.out.println("Введите данные уравнения");
System.out.println("ax^2+bx+c");
{
System.out.println("Введите a");
int a=Reader.nextInt();
System.out.println("Введите b");
int b=Reader.nextInt();
System.out.println("Введите c");
int c=Reader.nextInt();
{
System.out.println("Вы ввели"+ a +"x^2+"+ b +"x+"+c);
int d,b1;
double d1,x1,x2,x11,x22;
b1=b*b;
d=b1-4*a*c;
d1=Math.sqrt(d);
x11=-b+d1;
x1=x11/2*a;
x22=-b-d1;
x2=x22/2*a;
System.out.println("x1 равен:"+x1+"x2 равен:"+x2);
}
}
}
}
Answer the question
In order to leave comments, you need to log in
That's what Sergei meant.
You should have moved the Scanner inside the main method. + Instead, Reader use sc
import java.lang.*;
import java.io.Reader;
import java.util.Scanner;
public class karlic20 {
public static void main(String[]args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Введите данные уравнения");
System.out.println("ax^2+bx+c");
{
System.out.println("Введите a");
int a=sc.nextInt();
System.out.println("Введите b");
int b=sc.nextInt();
System.out.println("Введите c");
int c=sc.nextInt();
{
System.out.println("Вы ввели"+ a +"x^2+"+ b +"x+"+c);
int d,b1;
double d1,x1,x2,x11,x22;
b1=b*b;
d=b1-4*a*c;
d1=Math.sqrt(d);
x11=-b+d1;
x1=x11/2*a;
x22=-b-d1;
x2=x22/2*a;
System.out.println("x1 равен:"+x1+"x2 равен:"+x2);
}
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question