Design and create a program to be used by an interior decorator to estimate the cost of painting a room. The decorator needs to enter the following input data:
• the height of the room (between 2 and 6 metres),
• the length of all 4 walls (between 1 and 25 metres).
The program should calculate the total area of the room to be painted (4 walls only, without the ceiling). The program should allow a choice of three paints:
• luxury quality, which costs £1.75 per square metre
• standard quality, which costs £1.00 per square metre
• economy quality, which costs £0.45 per square met
The decorator should also be able to choose to use undercoat paint if required, which costs £0.50 per square metre.
The program should display an itemised bill with a total.
As part of the design, you need to include the following:
data design
algorithm
user interface design
design of test plan
I dont know where to start, could someone help me please, i have tried making the program but now i am in desperate need of help.
Hi Hack
Thanks for your reply, hmm yes i understand that.
Basically i have created the layout of the program.
I have experimented with some codes. but not much luck
Code:
Option Explicit
Dim FirstNumber As Integer
Dim SecondNumber As Integer
Dim ThirdNumber As Integer
Dim Total As Integer
Private Sub Command1_Click()
ElseIf (Add = False) And _
(Minus = False) And _
(Divide = False) And _
(Mulitiply = False) Then
MsgBox "Please choose an Option"
ElseIf (OptAdd) Then
End If
If Add = True Then
lblResult = Val(text01.Text) + Val(text02.Text)
ElseIf Minus = True Then
lblResult = Val(text01.Text) - Val(text02.Text)
ElseIf Multiply = True Then
lblResult = Val(text01.Text) * Val(text02.Text)
ElseIf Divide = True Then
lblResult = Val(text01.Text) / Val(text02.Text)
End If
End Sub
Private Sub Command2_Click()
End Sub
Private Sub cmdAbout_Click()
MsgBox ("Program: Interior Decorating Estimation Calculator 1.0, Author: 277302, ID Code: 277302")
End Sub
Private Sub cmdEnter_Click()
Dim Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec As String
Dim strNumber As String
Dim blnNumberValid As Boolean
Jan = "January"
Feb = "February"
Mar = "March"
Apr = "April"
May = "May"
Jun = "June"
Jul = "July"
Aug = "August"
Sep = "September"
Oct = "October"
Nov = "November"
Dec = "December"
blnNumberValid = False
Do
strNumber = InputBox("Please type a number between 2 and 6", "Data Entry")
If strNumber = "" Or Not IsNumeric(strNumber) Then
MsgBox "[WARNING - Invalid Number] Please enter a number between 2-6"
ElseIf CInt(strNumber) < 1 Or CInt(strNumber) > 6 Then
MsgBox "[WARNING - Number exceeds 6] Please enter a number between 2-6"
Else
blnNumberValid = True
End If
Loop Until blnNumberValid = True
If strNumber = "1" Then
Text2.Text = " 31"
Text1.Text = (Jan)
End If
If strNumber = "2" Then
If Year(Date) Mod 400 = 0 Then
Text2.Text = "29"
Text1.Text = (Feb)
ElseIf Year(Date) Mod 100 = 0 Then
Text2.Text = "28"
Text1.Text = (Feb)
ElseIf Year(Date) Mod 4 = 0 Then
Text2.Text = "29"
Text1.Text = (Feb)
Else: Text2.Text = "28"
Text1.Text = (Feb)
End If
End If
If strNumber = "3" Then
Text2.Text = " 31"
Text1.Text = (Mar)
ElseIf strNumber = "4" Then
Text2.Text = " 30"
Text1.Text = (Apr)
ElseIf strNumber = "5" Then
Text2.Text = " 31"
Text1.Text = (May)
ElseIf strNumber = "6" Then
Text2.Text = " 30"
Text1.Text = (Jun)
Else
blnNumberValid = True
If IsNumeric(Text1.Text) = False Or _
IsNumeric(Text2.Text) = False Then
MsgBox "Incorrect Value: Please enter the correct value"
ElseIf (Text2.Text) = "0" And (OptDivide) Then
MsgBox "It is not possible to divide by zero"
ElseIf (Add = False) And _
(Minus = False) And _
(Divide = False) And _
(Mulitiply = False) Then
MsgBox "Please choose an Option"
ElseIf (OptAdd) Then
End If
If Add = True Then
lblResult = Val(Text1.Text) + Val(Text2.Text)
ElseIf Minus = True Then
lblResult = Val(Text1.Text) - Val(Text2.Text)
ElseIf Multiply = True Then
lblResult = Val(Text1.Text) * Val(Text2.Text)
ElseIf Divide = True Then
lblResult = Val(Text1.Text) / Val(Text2.Text)
End If
End If
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub Label3_Click()
End Sub
Private Sub Form_Load()
Form1.Show
FirstNumber = InputBox("Enter the height of the room (Between 2-6)")
SecondNumber = InputBox("Enter the length of all 4 walls (Between 1-25)")
Total = FirstNumber + SecondNumber
Print "The total is", Total
End Sub
I would start by using 2 textboxes for measuerments with a label to display the results to get the sq footage.
Then val(label1.caption) = val(label1.caption) + val(text1) * val(text2)
Then it's just a matter of displaying the results in 3 other labels
label2.caption = 1.75 * val(label1.caption)
label3.caption = 1.00 * val(label1.caption)
etc
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
Before you try to do anything more, I would strongly suggest you clean everything out of your code that is not related to your current project.
Re-using old code can save tons of time in the appropriate situations, but simply throwing old subroutines and event handlers into an unrelated project without reason will cause more problems for you.
I can see at least two other projects lurking in the code you posted, and their addition makes your code hard to understand, as well as probably affecting how it runs. When those are stripped out, your current relevant code is probably only about 20 lines which is MUCH easier to handle.
I think that you're just a bit overwhelmed with this project, but if you take it slow and steady and think through each phase, it won't be very difficult.
You can choose to either go the Ad Hoc method of development, or a designed development. I would recommend the latter, since you are required to submit written designs plans. You should think through the design of your project before you start the coding, otherwise you will get lost in the code.
Sit down and think through the actions and requirements a user would do and need. This will give you your design specifications (IE what you need), and may also give you an idea of the sort of error handling and methods/Functions you will need too.
THEN you can start your programming. If you're still unsure of where to start, you can take a top-down approach and mimic the actions a user would do on your form. As you do each action, write any supporting code that is needed. (IE the code behind a button the user would click)
This approach can break a big project down into tiny pieces, however it can make things harder for you later on because you may not see how pieces fit together at first, and you may then have to change code you've already written. (Since this is a relatively small project, you probably don't have to worry about that, though.)
THEN, if you run into specific problems or bugs/errors you can't resolve, you can come back here or to your teacher (?) and ask more specific questions knowing that you've already put plenty of effort into your work.
Hello NanoInfinity
I have cleaned out my codes and removed the codes from previous projects.
I tottaly understand what you mean and thank you. I have kept the required codes for the about button and exit.
Code:
Private Sub Command1_Click()
End Sub
Private Sub Command2_Click()
End Sub
Private Sub cmdAbout_Click()
MsgBox ("Program: Interior Decorating Estimation Calculator 1.0, Author: 277302, ID Code: 277302")
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub Label3_Click()
End Sub
The reason why i am not taking it easy is because I have to make this program before the 3rd of june which is the deadline for it.
Thank you for your advice there. I have sat down and thought about it
To break it down
Text1: (height) The user will input the height for the room and there is a validation limit of 2 to 6 metres.
Text2: (Length) The user will also input the length for the room (all four walls) which has a validation limit of 1 to 25 metres.
Label1 (Not created yet) I will create this to display the output of the estimation of the length, height and cost.
Option box1: I will create an option box so the user can only click on one option and they are for the costs of the paints, I think that this might have to integrated with the height and length.
Checkbox1: I will create a checkbox and there is only one option. If selected (checked) then the price should be increased to 50p per square metre.
...
Now i am stuck, not sure what to do.
Please help
Thanks
Originally Posted by nanoinfinity
Before you try to do anything more, I would strongly suggest you clean everything out of your code that is not related to your current project.
Re-using old code can save tons of time in the appropriate situations, but simply throwing old subroutines and event handlers into an unrelated project without reason will cause more problems for you.
I can see at least two other projects lurking in the code you posted, and their addition makes your code hard to understand, as well as probably affecting how it runs. When those are stripped out, your current relevant code is probably only about 20 lines which is MUCH easier to handle.
I think that you're just a bit overwhelmed with this project, but if you take it slow and steady and think through each phase, it won't be very difficult.
You can choose to either go the Ad Hoc method of development, or a designed development. I would recommend the latter, since you are required to submit written designs plans. You should think through the design of your project before you start the coding, otherwise you will get lost in the code.
Sit down and think through the actions and requirements a user would do and need. This will give you your design specifications (IE what you need), and may also give you an idea of the sort of error handling and methods/Functions you will need too.
THEN you can start your programming. If you're still unsure of where to start, you can take a top-down approach and mimic the actions a user would do on your form. As you do each action, write any supporting code that is needed. (IE the code behind a button the user would click)
This approach can break a big project down into tiny pieces, however it can make things harder for you later on because you may not see how pieces fit together at first, and you may then have to change code you've already written. (Since this is a relatively small project, you probably don't have to worry about that, though.)
THEN, if you run into specific problems or bugs/errors you can't resolve, you can come back here or to your teacher (?) and ask more specific questions knowing that you've already put plenty of effort into your work.
I would start by using 2 textboxes for measuerments with a label to display the results to get the sq footage.
Then val(label1.caption) = val(label1.caption) + val(text1) * val(text2)
Then it's just a matter of displaying the results in 3 other labels
label2.caption = 1.75 * val(label1.caption)
label3.caption = 1.00 * val(label1.caption)
etc
put your sets of numbers Height * width into the textboxes and click the command button
erase the previous entry and put your next set of numbers into the textboxes
click the command button
also you may want to restrict entry to numbers only in the textboxes etc
Lots of examples in the code bank
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
I forgot to mention, have you named all your controls? (Controls, if you don't already know, are all the things that the user can interact with. Text boxes, options, labels, the form itself, etc.) Naming your controls well, with names that clearly indicate what type of control they are and what their purpose is, will also help you a lot. For example, you could call the textbox that the user inputs the height of the room something like "txtRoomHeight". If you want more info on common naming conventions, look up "hungarian variable naming" on Google, maybe.
Your user will input values into both of the text boxes - then what?
Well, you'll want to check the validation. Doubleclick the text boxes and in each text box's Change event (the empty subroutine should have been automatically created for you) fill in the code that checks the user's input.
Then, ask again, "what comes next?"
Well, the user will probably want to know the total area they are required to paint. You could display this in a label. There are a few ways you could do this, but this way I'd suggest is to write a new sub of your own to update the Caption property of the label box with the calculated wall area, and then call that subroutine from within each seperate textbox Change event. (You could put the calculation code in a Button, or directly in both textboxes, but you don't really need an extra button and there's no point in repeating code.)
You should now have something structured like this: (Note: any line that starts with an apostrophe (') is called a Comment. VB will ignore any text that follows the (') on that line. Comments are very useful for explaining things in your code - both for you and whoever comes after you.)
Code:
'The option explicit VB option forces the programmer to declare (Dim) all variables used
Option Explicit
Private Sub txtRoomHeight_Change()
'---Your validation checks here
Call updateAreaLabel
End Sub
Private Sub txtWallLength_Change()
'---Your validation checks here
Call updateAreaLabel
End sub
Private Sub updateAreaLabel()
lblAreaLabel.Caption = 'Your area calculation here, using Val(txtRoomHeight.Text) and
'Val( txtWallWidth.Text)
'The Val() method converts a String to a number
End Sub
You will have to decide how to display your bill and update that, too.
Anyway, the next thing the user is going to do is select an option button. You don't have to do much here except remember which option the user chose. One possibility is to declare a form-scope variable (At the very top, below "Option Explicit") perhaps called price that is updated when an option button is selected. (Have you learned about Variable Scope yet?)
Code:
Dim dPrice As Double 'Tells the compiler to set aside room for a Double-sized value.
'A Double value can hold fractional values, EX: 2.0, 3.14159
You can change and retrieve the Value of an option button or a checkbox by "controlName.Value" (EX: "optLuxery.Value"). The .Value property is a Boolean value, meaning it is either True or False. When a box is unchecked, or an option is not selected, the Value is "False", otherwise if it is selected or checked, it is "True". Use this to see which option button and check box is marked.
Finally, you need to fill in the rest of your bill, depending on what values were selected, and then calculate the total.
Hint: if you want to add something to the end of existing text, you can concatenate it using the "&" sign. Say I wanted to add "Goodbye" to the end of whatever was in lblSpeech :
Another thing that may be useful to you is how to make multiple lines of text. The word that tells vb you want to start a new line (Similar to hitting "Enter" on your keyboard) is "vbCrLf". You don't include the quotes, and it cannot be inside of a string, or else it won't make a new line. This might help you to make your bill summary. Example:
In future projects if you're stuck, just go step by step through the application asking "What will the user want to do next?" until you have all the components in place. I understand how difficult it can be when you don't have any knowledge of the provided library functions or syntax, but VB is very helpful. If you ever want to know the properties of methods of a certain object (control), just type the variable name and then a dot (.) and a list of things should come up.
The Help files are also quite useful for explaining what methods and functions do what things, and you can search for particular things if you're looking for a function that does something specific.
I tried to give advice without doing the Design Aspect of the project for you, so you will still have to figure some things out on your own... which is (aside from laziness) one of the major traits of a programmer.