Question
Intro to programming using java, problem 9.1 The Rectangle Class, the bold is where I am getting the errors package javaapplication3; public class JavaApplication3 {
Intro to programming using java, problem 9.1 The Rectangle Class, the bold is where I am getting the errors
package javaapplication3;
public class JavaApplication3 {
/** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here //UML Class Diagram /************************************************** * Rectangle * * ------------------------------------------------* * width: double * * height: double * * Rectangle() * * Rectangle(newWidth: double, newHeight: double) * * getArea(): double * * getPerimeter(): double * ***************************************************/
double width; double height;
Rectangle() { width = 1; height = 1; }
Rectangle(double newWidth, double newHeight) { width = newWidth; height = newHeight; }
double getArea() { return width * height; }
double getPerimeter() { return 2 * (width + height); } Rectangle rectangle1 = new Rectangle(4, 40);
Rectangle rectangle2 = new Rectangle(3.5, 35.9);
System.out.println(" Rectangle 1"); System.out.println("-------------"); System.out.println("Width: " + rectangle1.width); System.out.println("Height: " + rectangle1.height); System.out.println("Area: " + rectangle1.getArea()); System.out.println("Perimeter: " + rectangle1.getPerimeter());
System.out.println(" Rectangle 2"); System.out.println("-------------"); System.out.println("Width: " + rectangle2.width); System.out.println("Height: " + rectangle2.height); System.out.println("Area: " + rectangle2.getArea()); System.out.println("Perimeter: " + rectangle2.getPerimeter()); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started