Results 1 to 5 of 5
 10302012, 10:23 PM #1Member
 Join Date
 Oct 2012
 Posts
 2
 Rep Power
 0
Need help in a java assignment trying to find the surface area of a room!
I need to write a java program that will calculate the surface area of a room to apply paint to the walls (no doors or windows and the floor is excluded). I am a beginner at programming in java and have run into a lot of trouble trying to write the program). So far what i have is 
Any help would be greatly appreciated!! Thanks, Mike
Class myRoom
public class myRoom {
// Attributes
private double length;
private double height;
private double width;
// Constructers
public myRoom (double length, double height, double width){
length=4.0;
height=2.0;
width=3.5;
// Methods
// Compute the surface area of walls to be covered.
public double myRoom(){
//areaToPaint = (2(length + width) height) + (length width)
double myRoom;
myRoom = (2*(length + width)*height) + (length + width)
return myRoom
system.out.println("The surface area of the room is" + myRoom);
}

Re: Need help in a java assignment trying to find the surface area of a room!
Please use code tags when posting code so that it retains its formatting and is readable. The link in my signature will show you how to do this.
As for your question, just what exactly are you stuck on? Please tell us as much as possible about your problem so that we can help you best.
 10302012, 11:54 PM #3Member
 Join Date
 Oct 2012
 Posts
 2
 Rep Power
 0
Re: Need help in a java assignment trying to find the surface area of a room!
Below is the assignment i have been asked to complete. It involves writing a program to find the surface area of a room to see how much paint would be required to paint it. My attempts so far just to write something that will calculate the surface area have all failed and any pointers would be very helpful. My current attempts won't compile so i know their are some programming errors in my code, but i'm not even sure if it's just my coding errors or i am writing completely the wrong code as i am a complete beginner in programming. Any help/ tips/ pointers would be much appreciated. Thanks, Mike
Requirements.
Design, implement and test a Java application program that calculates the
amount and cost of paint required to paint a room as described below. The dimensions of a
room (real numbers given in metres) are given as its length, width and height. The four walls
and ceiling must be painted (but not the
oor). You should ignore any doors or windows.
The coverage of the paint is 13m2
per litre. You should calculate the area to paint (a real
number in m2
) and the actual amount of paint in litres that is needed for the job (a real
number in litres). Additionally assume that the paint comes in tins of 5 litres and each tin
costs $15.43. Calculate the number of tins required (as a whole number of tins) and the cost
of paint you will need to buy. Note that you must buy the paint in whole tins (you can't buy
a fraction of a tin). You can assume that the values input for the length, width and height
are greater than or equal to zero, i.e. you don't have to test for negative inputs.
The calculations are as follows assuming length, width, and height are in metres. Note
that ceiling returns a value that is the integer greater than or equal to its argument.
areaT oP aint = (2(length + width) height) + (length width)
amountOfP aint = areaT oP aint 13
numberOfT ins = ceiling(amountOfP aint 5)
costOfP aint = numberOfT ins 15:43
You should design, implement and test a Java program which, given the size of a room
dened in terms of inputs for length, width and height, outputs the area to be painted, the
amount of paint required, the number of tins required and the cost of the paint.
1ab4 2
Example length=4.5, width=3.5, height=2.0,
areaT oP aint = (2(4:5 + 3:5) 2:0) + (4:5 3:5)
= 32 + 15:75 = 47:75m2
amountOfP aint = (47:75) 13 = 3:6730769 litres
numberOfT ins = ceiling(3:6730769 5)
= ceiling(0:73461538)
= 1
costOfP aint = 1 15:43 = $15:43
The output from this example is given below.
$ java PaintCostUser
Please input room length: 4.5
Please input room width: 3.5
Please input room height: 2.0
Surface to be painted: 47.75
Amount of Paint in litres: 3.67
Number of tins: 1
Paint Cost: 15.43
 10312012, 12:57 AM #4
Re: Need help in a java assignment trying to find the surface area of a room!
Hello and welcome! Please use [code][/code] tags when posting code so we can easily read it!
Forum Rules
Guide For New Members
BB Code List  Java Programming Forum
Without seeing your complete code, we cannot point out the errors. Without knowing what the errors are we have even more trouble. Please post your complete code (with code tags please) and all errors you get (complete stack trace please). We can move on from there! :D
 10312012, 02:08 AM #5
Similar Threads

Java Compiling Issue w/ 3D Surface Plot
By cms370 in forum New To JavaReplies: 0Last Post: 11202011, 07:06 PM 
Can't access clipboard in java chat room
By logicada in forum Java AppletsReplies: 1Last Post: 10242011, 10:04 PM 
Creation of a curved surface as an airfoil using java AWT
By murdplacid in forum Java 2DReplies: 9Last Post: 09272010, 06:53 PM 
Java Developer Needed/Perm/NJ/Brokerage...lots of room for growth
By shagans982 in forum Jobs OfferedReplies: 1Last Post: 08092008, 12:55 PM
Bookmarks