i need some help with a question please

• 11-25-2012, 02:18 AM
javanewbe
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 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 houseType;
private double sellingPrice;

public House( String address, String type, double price)
setType(type);
setPrice(price);
}
{
}

}

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

}
• 11-25-2012, 03:43 AM
Fubarable
Re: i need some help with a question please
Can you tell us what errors you are encountering?
• 11-25-2012, 04:07 AM
javanewbe
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
• 11-25-2012, 04:08 AM
javanewbe
Re: i need some help with a question please
can it be i'm encountering errors beacause my array isnt in my main class?
• 11-25-2012, 04:10 AM
Fubarable
Re: i need some help with a question please
Have a look: declaring arrays
• 11-25-2012, 04:11 AM
Fubarable
Re: i need some help with a question please
Quote:

Originally Posted by javanewbe
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.