Errors:
File: F:\lab_2.java [line: 36]
Error: next cannot be resolved or is not a field
File: F:\lab_2.java [line: 38]
Error: next cannot be resolved or is not a field
File: F:\lab_2.java [line: 40]
Error: next cannot be resolved or is not a field
File: F:\lab_2.java [line: 42]
Error: Duplicate local variable outa
Code:
else if (choice==1){
int a;
int b;
int c;
System.out.println("what is a ?");
a=myscan.next ; //line 36
System.out.println("what is b ?");
b=myscan.next ; //line38
System.out.println("what is c ?");
c=myscan.next ; //line40
double outa =(b + Math.sqrt((b*b)-4*a*c))/(2*a);
double outa =(b - Math.sqrt((b*b)-4*a*c))/(2*a); //line42
}
//quadratic formula ^^^^
The error means that "next" is not a valid method or field on the variable myscan, which I assume is a Scanner. if "myscan" IS a Scanner, I think you're looking for input, so:
a=myscan.nextInt();
Also, you assign b+ and b- to outa
, so you're overwriting the first answer with the second.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.