Is this going to work out in the end?

Page 1 of 1

2 Replies - 2642 Views - Last Post: 08 December 2011 - 10:34 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=258706&amp;s=472ae467167d0740cdf7729838e435cf&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 MCarbone

Reputation: 0
• Posts: 19
• Joined: 27-October 11

Is this going to work out in the end?

Posted 06 December 2011 - 06:13 AM

The Westfield Carpet Company has asked you to write an application that calculates the price of carpeting for rectangular rooms. To calculate the price, you multiply the area of the floor(width times length) by the price per square foot of carpet. For example, thearea of floor that is 12 feet long and 10 feet wide is 120 square feet. To cover that floor with carpet that costs \$8 per square foot would cost \$960 (12x10x8=960).
You should create a class named Rectangle with the following properties:
Width : A single
Length : A single
Area : A single
The Area property should be read-only. Provide a method named CalcArea that calculates widthxlength and stores the result in the Area property.
Next, create a class named Carpet with the following properties:
Color: A string
Style: A string
Price: A decimal

Here is the code I have so far...
```Public Class Form1
Public Class Rectangle
'member variable
Private sngWidth As Single      'holds width
Private sngLength As Single     'holds height
Private sngArea As Single       'holds area
'constructor
Public Sub New()
sngWidth = CSng(String.Empty)
sngLength = CSng(String.Empty)
sngArea = CSng(String.Empty)
End Sub
'Width property procedure
Public Property Width() As Single
Get
Return sngWidth
End Get
Set(value As Single)
sngWidth = value
End Set
End Property

'Height property procedure
Public Property Length() As Single
Get
Return sngLength
End Get
Set(value As Single)
sngLength = value
End Set
End Property

Public ReadOnly Property Area() As Single
Get
'calculation for area
Dim sngArea As Single
'Determine area of room

End Get
End Property
End Class
End Class

```

Am I even close to on the right track?? I am trying to take code from the book and manipulate it as I do NOT understand this AT all!
I have no clue how to do the CalcArea portion either. Any tips on that would be greatly appreciated!

Is This A Good Question/Topic? 0

Replies To: Is this going to work out in the end?

#2 tlhIn`toq

• Xamarin Cert. Dev.

Reputation: 6528
• Posts: 14,435
• Joined: 02-June 10

Re: Is this going to work out in the end?

Posted 06 December 2011 - 08:38 AM

Area of a square is width times length

Beyond that, see FAQ 13 about talking to your instructor since you are totally lost.

FAQ (Frequently Asked Questions - Updated Nov 2011

Spoiler

Reminder to all: This is course homework. We do NOT provided completed code/solutions for homework. We can help the OP understand specific concepts they are having trouble with or specific errors they don't understand.

Of course they have to tell us the specific errors first, and not just "Can you help me with my homework, its due soon."

The stages of asking for homework help on a forum

This post has been edited by tlhIn`toq: 06 December 2011 - 08:39 AM

#3 deery5000

• D.I.C Lover

Reputation: 87
• Posts: 1,097
• Joined: 09-May 09

Re: Is this going to work out in the end?

Posted 08 December 2011 - 10:34 AM

you have declared the functionalality of the width , length (set, get)

you simply do the same now for the area. The passge you have provided tells you how to do the calculations. You just need to add this to the function.

pass your values into the function and do the calculations and return the value.

eg dim getArea = new Rectangle
areaVal = getArea.area(your values to pass to function here for calculation)

areaVal now contains the result from your calculation returned from the area function

hope this helps
kevin