Results 1 to 5 of 5
  1. #1
    Dubmunky is offline Member
    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Default 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);
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default 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.

  3. #3
    Dubmunky is offline Member
    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Default 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
    de ned 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

  4. #4
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    6

    Default 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

  5. #5
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default Re: Need help in a java assignment trying to find the surface area of a room!

    From the code in the original post I see:

    5 syntax errors.
    4 semantic errors.
    1 violation of naming conventions.
    2 recommendations to rename methods/variables.

Similar Threads

  1. Java Compiling Issue w/ 3D Surface Plot
    By cms370 in forum New To Java
    Replies: 0
    Last Post: 11-20-2011, 06:06 PM
  2. Can't access clipboard in java chat room
    By logicada in forum Java Applets
    Replies: 1
    Last Post: 10-24-2011, 09:04 PM
  3. Replies: 9
    Last Post: 09-27-2010, 05:53 PM
  4. Replies: 1
    Last Post: 08-09-2008, 11:55 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •