Hello, I encountered the "cannot find symbol" problem:

class Quadrate { double a; Quadrate (double a){ this.a = a; } double perimeter() { double value = 4 * a; return value; } double square() { double value = a * a; return value; } double diagonal() { double value = Math.sqrt(a * a + a * a); return value; } } public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n; System.out.print("Введите кол-во квадратов: "); while (true) { if (!sc.hasNextInt()) { System.out.print("Некорректний тип введеного числа! Повторите попитку: "); sc.next(); } else { n = sc.nextInt(); break; } } Quadrate[] quadrates = new Quadrate[n]; for(int i = 0; i < quadrates.length; i++) { System.out.printf("Введите сторону %d - го: ", i + 1); double v = sc.nextDouble(); quadrates[i] = new Quadrate(v); } for(int i = 0; i < quadrates.length; i++) { System.out.printf("Периметр %d - го: %f", i + 1, qudrates[i].perimeter()); // ошибка System.out.printf("Площадь %d - го: %f", i + 1, qudrates[i].square()); // ошибка System.out.printf("Диагональ %d - го: %f", i + 1, qudrates[i].diagonal()); // ошибка } } } 

You can also enter only human side values, and if double - an error, if not difficult, help, please.

Closed due to the fact that the participants are off topic : , aleksandr barakin , D-side , zRrr , Grundy 12 May '16 at 8:08 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - Yuriy SPb, aleksandr barakin
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Below "cannot find symbol" the compiler shows which "symbol" is not located. The description of the error should be slightly more complete than "failed". According to the above code, the question arises - who is the Scanner? import java.util.Scanner; - there is? Or specify completely. - Sergey Mitrofanov
  • there is just not writing - Muscled Boy
  • scanner imported right away - Muscled Boy

1 answer 1

The cannot find symbol error itself indicates that symbol: variable qudrates

You have a typo. Your array is called quadrates , but in some lines you use qudrates

  • For sure. Thank. Just a little tired already, that did not notice the nonsense. But there is also the problem Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor (Scanner.java:864) at java.util.Scanner.next (Scanner.java:1485) at java.util. Scanner.nextDouble (Scanner.java:2413) at quadrate.Main.main (Main.java:46) - Muscled Boy
  • @MuscledBoy Try to find the answer to the question yourself. If that doesn't work, create another question. - Dmitry Dovgopoly
  • ok thanks and on this - Muscled Boy
  • The error was in the input number. 1.2, for example, will be 1.2 - correct - Muscled Boy