Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions

Question

help asp

Answered: 1 week ago

Question

Question May a taxpayer roll over money from an IRA to an HSA?

Answered: 1 week ago

Question

Question What is the doughnut hole in HSA coverage?

Answered: 1 week ago