I need help!!! im trying to get my sentinal to stop counting as my last value passed. Im imputting a value for a house,and its calculating a total price based on interest and stuff ive set up according to the house value. then pressing -1 to go onto the next house.the problem is, when i press the -1 it just keeps taking my house value as -1(my sentinal) i cant continue anything else without fixing this!!
heres my test:
public class AuctionTest
{
public static void main(String args[])
{
Auction pointer1=new Auction("Peter Dunphy\n15 Collins Drive\nKillester\nDublin 5");
Auction pointer2=new Auction("Katie Molloy\n10 New Road\nGlasnevin\nDublin 11");
pointer1.displayMessage();
pointer1.determineAfford();
pointer2.displayMessage();
pointer2.determineAfford();
}
}
and heres my main code:
import java.util.Scanner;
public class Auction
{
private String personName;
public Auction(String name)
{
personName=name;
}
public void setPersonName(String name)
{
personName=name;
}
public String getPersonName()
{
return personName;
}
public void displayMessage()
{
System.out.printf("These are the details on file for \n%s\n",getPersonName());
}
public void determineAfford()
{
Scanner input=new Scanner(System.in);
int houseCounter;
double houseCost;
double totalCost;
double interest;
double peter;
double katie;
houseCounter=1;
peter=550000;
katie=1500000;
System.out.println("Enter house cost or -1 to quit");
houseCost=input.nextDouble();
while (houseCost !=-1)
{
houseCounter=houseCounter+1;
System.out.println("Enter house cost or -1 to quit");
houseCost=input.nextDouble();
houseCost=houseCost;
}
if (houseCost<=100000)
{
interest=0;
totalCost=houseCost+interest;
System.out.printf("Total cost is %.2f",totalCost);
}
if (houseCost<=200000)
{
interest=(houseCost-100000/100)*5;
totalCost=houseCost+interest;
System.out.printf("Total cost is %.2f",totalCost);
}
if (houseCost<=300000)
{
interest=(houseCost-200000/100)*6+5000;
totalCost=houseCost+interest;
System.out.printf("Total cost is %.2f",totalCost);
}
if (houseCost<=400000)
{
interest=(houseCost-300000/100)*7+5000+6000;
totalCost=houseCost+interest;
System.out.printf("Total cost is %.2f",totalCost);
}
if (houseCost>500000)
{
interest=(houseCost-400000/100)*8+5000+6000+7000;
totalCost=houseCost+interest;
System.out.printf("Total cost is %.2f",totalCost);
}
}
}