Results 1 to 6 of 6
  1. #1
    javanewbe is offline Member
    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Default i need some help with a question please

    i need help to write a code for the folllowing question.
    i need help to write a code for the folllowing question.

    A realtor wishes to track her commissions of house sales. The information that she collects is as follows:

    house address a string
    house type a string ( split level, bungalow, etc.)
    sale price a double

    She wishes to calculate the commission for each house as well as find the total commission earned for all houses. Commission is calculated as 7% of the first $100,000 and 3.5% of any amount over $100,000. Create an application that will accept an array of house objects and return the total commission. The application should also be able to calculate the commission earned on each house.

    ***Use the following test data:
    123 Main Street, Split level, 250000.00
    456 Elm Street, Bilevel, 150000.00
    789 Oak Ave, Bungalow, 95000.00
    ***
    i already made a class House and it compiles with no errors
    public class House
    {
    private String houseAddress;
    private String houseType;
    private double sellingPrice;

    public House( String address, String type, double price)
    { setAddress(address);
    setType(type);
    setPrice(price);
    }
    public void setAddress(String add )
    {
    houseAddress = add;
    }

    public String getAddress()
    { return houseAddress;
    }

    public void setType(String typ )
    {
    houseType = typ;
    }

    public String getType()
    {return houseType;
    }

    public void setPrice(double p )
    {
    sellingPrice = p;
    }

    public double getPrice()
    {return sellingPrice;
    }

    }
    but i attempted the HouseCommissions class and i am encountering some errors, can u please explain what i did wrong,, here is the code below


    import java.util.*;
    public class HouseCommissions
    {
    final private double commissionrate1= 0.07;
    final private double commissionrate2 = 0.035;
    double commission1;
    double commision2;

    Scanner in = new Scanner(System.in);
    House[] h= new House[3];

    h[0]= new House{123 Main Street, Split level, 250000.00};
    h[1]= new House{456 Elm Street, Bilevel, 150000.00};
    h[2]= new House{789 Oak, Bungalow, 95000.00};


    public double Commission(House[] h)
    {

    if( House[] h.getPrice<=100000.0)

    { commission1= (commissionrate1*h);
    System.out.println(commission1);
    }

    else { commision2= commissionrate2*h;
    System.out.println(commision2);
    }
    }

    }

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

  3. #3
    javanewbe is offline Member
    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Default Re: i need some help with a question please

    alot to be exact i think i can figure it out, can you tell me how to create an array with data already in lk an example so i can then try it and see if i could solve the problems

  4. #4
    javanewbe is offline Member
    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Default Re: i need some help with a question please

    can it be i'm encountering errors beacause my array isnt in my main class?

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: i need some help with a question please

    Quote Originally Posted by javanewbe View Post
    can it be i'm encountering errors beacause my array isnt in my main class?
    It's hard to tell since you're not yet showing the messages. Usually the error messages are pretty self-explanatory.

Similar Threads

  1. Replies: 2
    Last Post: 05-25-2012, 05:00 PM
  2. Java Question [Beginner Question]
    By joker760 in forum New To Java
    Replies: 3
    Last Post: 12-13-2011, 05:01 PM
  3. question posted by indissa: library question.
    By Fubarable in forum New To Java
    Replies: 2
    Last Post: 11-18-2011, 02:14 AM
  4. Question concerning question marks and colons
    By jim01 in forum New To Java
    Replies: 17
    Last Post: 01-14-2011, 01:05 AM
  5. Question mark colon operator question
    By orchid in forum Advanced Java
    Replies: 9
    Last Post: 12-19-2010, 09:49 AM

Posting Permissions

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