Есть какие нибудь идеи как это починить? Не знаю, что я сделал не так. Спасибо!
У меня следующая ошибка:
"Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol symbol: class Rectangle location: class TestRectangle at TestRectangle.main(TestRectangle.java:25)"
Это мой код:
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package week7assignment;
/**
*
* @author Casey
*/
public class TestRectangle {
public static void displayMenu() {
System.out.println("1. Set length");
System.out.println("2. Set width");
System.out.println("3. Calculate Area");
System.out.println("4. Calculate Perimeter");
System.out.println("5. Exit");
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Rectangle rect = new Rectangle();
try {
int choice = 0;
while (choice != 5) {
System.out.println("Enter your choice (1-5):");
choice = input.nextInt();
switch (choice) {
case 1:
System.out.print("Enter length: ");
double length = input.nextDouble();
rect.setLength(length);
break;
case 2:
System.out.print("Enter width: ");
double width = input.nextDouble();
rect.setWidth(width);
break;
case 3:
System.out.println("Length = " + rect.getLength());
System.out.println("Width = " + rect.getWidth());
System.out.println("Area = " + rect.area());
break;
case 4:
System.out.println("Length = " + rect.getLength());
System.out.println("Width = " + rect.getWidth());
System.out.println("Perimeter = " + rect.perimeter());
break;
case 5:
System.exit(0);
}
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
Пожалуйста, прочтите сообщение об ошибке, в нем указана точная причина того, что пошло не так.
@Rogue Да, у меня есть другая программа под названием Rectangle в том же пакете.
@JerryChin Большое спасибо, вы действительно очень помогли.




Откуда взялся
Rectangle? Это в том же пакете?