Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is my code.. package roomdimension; /** * * @author alree */ import java.util.Scanner; public class RoomDimension { int length; int width; public RoomDimension(int length,

Here is my code..

package roomdimension;

/** * * @author alree */ import java.util.Scanner;

public class RoomDimension {

int length; int width;

public RoomDimension(int length, int breadth) { this.length = length; this.width = breadth; }

public int area() { return length*width; } }

public class RoomCarpet { RoomDimension roomDimension; int costPerSquareFeet;

public RoomCarpet(RoomDimension roomDimension, int costPerSquareFeet) { this.roomDimension = roomDimension; this.costPerSquareFeet = costPerSquareFeet; }

public int totalCost() { return roomDimension.area()*costPerSquareFeet; } }

public class CarpetingPrice { static int roomLength; static int roomWidth; static int costOfCarpetPerSquareFeet; static Scanner userValues = null; static RoomDimension roomDimension = null; static RoomCarpet roomCarpet = null;

public static void main(String[] args) { System.out.print("Enter room length in feet: "); userValues = new Scanner(System.in); roomLength = userValues.nextInt();

System.out.print(" Enter room width in feet: "); userValues = new Scanner(System.in); roomWidth = userValues.nextInt();

System.out.print(" Enter cost of carpet per square feet in $: "); userValues = new Scanner(System.in); costOfCarpetPerSquareFeet = userValues.nextInt();

roomDimension = new RoomDimension(roomLength, roomWidth);

roomCarpet = new RoomCarpet(roomDimension, costOfCarpetPerSquareFeet);

System.out.println(" Cost of carpet for a room of " + "Length: " + roomLength + " feet, Width: " + roomWidth + " feet and Area: " + roomDimension.area() + " square feet is $" + roomCarpet.totalCost()); } }

I am getting the following error for public class CarpetingPrice and public class RoomCarpet. The compiler says, "error: class, interface, or enum expected }"

PLEASE HELP!!! :(image text in transcribed

23h 24 public class RoomCarpet f 26 27 RoomDimension roomDimension: int costPersquareFeet; 29 30 31 32 public RoomCarpet (RoomDimension roomDimension, int costPerSquareFeet) this.roomDimensionroomDimension; this .costPerSquareFeet = costPerSquareFeet; 34 35 36 37h 38 public int totalcost) return roomDimension.area O costPerSquareFeet, public class CarpetingPrice t 40 41 42 43 static int roomiength: static int roomridth; static int costofcarpetPerSquareFeet static Scanner uservalues = null; Output-RoomDimension (cleanjar) x lingI source tile t CUserslalree\Documents NetBeansProjects RoomDimensionisrclroomdimensionRoomDimension.java:7l:eo class, interface, or enm expected l error C:\Userslalree\DocumentsNetBeansProjects\RoomDimensionnbproject\build-impl.xml: 930: The following error occurred while executing this line: C:Userslalree Documents NetBeansProjects RoomDimension nbprojectibuild-imp1.xml:270: Compile failedi see the compiler error output for details BUILD FAILEDtotal time: 2 seconds)

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions