Question
package rectangle; public class Rectangle { private int height; private int width; public Rectangle(int aHeight, int aWidth) { super(); height = aHeight; width = aWidth;
package rectangle;
public class Rectangle { private int height; private int width;
public Rectangle(int aHeight, int aWidth) { super(); height = aHeight; width = aWidth; }
public int getHeight() { return height; }
public int getWidth() { return width; }
public void setHeight(int aHeight) { height = aHeight; }
public void setWidth(int aWidth) { width = aWidth; }
public int computeArea() { return width * height; }
public int compputeCircumference() { return 2 * (width + height); } }
package rectangle;
import java.util.Scanner;
public class RectangleApp { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter height and width of Rectangle: "); Rectangle r = new Rectangle(sc.nextInt(), sc.nextInt()); System.out.println("Area: "+r.computeArea()); System.out.println("Circumference: "+r.compputeCircumference()); } }
Currently, I have these two codes. One is to find the area of a rectangle, and the other is a driver. I have one error in the driver code, in the line " Scanner sc = new Scanner(System.in); ". the sc after Scanner is highlighted as incorrect, and my TA told me I didn't use the Scanner object "sc" you created. Can someone tell me how I can fix this?
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