/** Write a class Square whose constructor receives the length of the sides.Then supply methods to compute thearea and perimeter of the square.Also compute the length of the diagonal using the Pythagorean Theorem.Use the following class as a template

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/05 18:36:29
/** Write a class Square whose constructor receives the length of the sides.Then supply methods to compute thearea and perimeter of the square.Also compute the length of the diagonal using the Pythagorean Theorem.Use the following class as a template

/** Write a class Square whose constructor receives the length of the sides.Then supply methods to compute thearea and perimeter of the square.Also compute the length of the diagonal using the Pythagorean Theorem.Use the following class as a template
/** Write a class Square whose constructor receives the length of the sides.
Then supply methods to compute the
area and perimeter of the square.
Also compute the length of the diagonal using the Pythagorean Theorem.
Use the following class as a template your tester class
*/
public class Square {
\x05 public Square(double sideLength)
\x05 {
\x05\x05Square mySquare = new Square();
\x05 }
\x05 public double getArea()
\x05 {
\x05\x05double area = sideLength * sideLength;
\x05\x05return area;
\x05 }
\x05 public double getPerimeter()
\x05 {
\x05\x05double perimeter = 4 * sideLength;
\x05\x05return perimeter;
\x05 }
\x05 public double getDiagonalLength()
\x05 {
\x05\x05double diagonal = Math.sqrt(sideLength * sideLenght + sideLength * sideLength);
\x05\x05return diagonal;
\x05 }
}
Square mySquare = new Square();
error:constructor Square in class Square cannot be applied to given types;
double area = sideLength * sideLength;
error:cannot find symbol
double perimeter = 4 * sideLength;
error:cannot find symbol
double diagonal = Math.sqrt(sideLength * sideLenght + sideLength * sideLength);
error:cannot find symbol
anyone can help?
thx sooo much
我另外两个程序也都有 cannotfindsymbol的问题 到底应该怎样啊

/** Write a class Square whose constructor receives the length of the sides.Then supply methods to compute thearea and perimeter of the square.Also compute the length of the diagonal using the Pythagorean Theorem.Use the following class as a template
如果你的程序这么写,那么很明显你的后面的方法中使用的sideLength没有定义
你在外面加个double sideLength;就可以了.因为你在第一个构造方法中定义了double sideLength它只能在它那个方法里面用,所以你必须定义一个double sideLength为全局变量,后面的就不会报错了

一般地,对于反应:m A + n B ® x C + y D DrSmq = åSq,(生成物) - åSq,(反应物) = [x Sq,C + y Sq,D] – [m Sq,A + n Sq,B](DrSmq)(åSq)( [x Sq,C + y Sq,D] – [m Sq,A + n Sq,最好举一个实例说明一下, Write about your class 2.下列程序运行的结果是?typedef char datatype;void main(){Sequeue *sq; datatype x=’e’,y=’c’; int i; SETNULL(sq); ENQUEUE(sq,’h’); ENQUEUE(sq,’r’); ENQUEUE(sq,y); x= DEQUEUE(sq); ENQUEUE(sq,x); x= DEQUEUE(sq); ENQUEUE(sq,’a Our headmaster asks the__ students to write to their parents once a weekA Class oneB class OneC class oneD Class One 循环队列的空条件A (sq.rear+1)%Maxsize==(sq.front+1)%Maxsize B (sq.rear+1)%Maxsize==sq.front+1 C (sq.rear+1)%Maxsize==sq.front D sq.rear==sq.front can‘t,you,in,a,class,write,letter连词成句 write.a. write a write a talk about your class then write? who____(write)best in your class write about a new product that youhave seen advertised recently.then talk about it with a class Who did the teacher_______the letter for the whole class?A has write B has written C have write D having written为什么选C?谢谢帮我分析! Who did the teacher_____the letter of thanks for thw whole class?A has write B has writtenC have write D having written The write has to take her children home after__ class every day.a.theb.ac./d.this 将下面的单词按照读音分类 /a:/:/ai/:class are i ask fine father car goodbye write I __(write) with a pencil in class.用所给单词的适当形式填空. you are to write a letter to exlain why you were absent from the night class 谁知道怎么写啊