Weird problem with my homework, statements out of order?
For my homework i need the statements to be in this order like this
http://img29.imageshack.us/img29/3613/outputd.jpg
but my code makes it come up like this??
http://img651.imageshack.us/img651/7049/output2.jpg
Can someone point me out how to order it?
Heres the 2 pages of code, thanks!
Code:
public class TestHousehold
{
public static void main(String[] args)
{
Household occupants = new Household();
occupants.methodThatUsesInstanceVariables();
}
}
Code:
import java.text.DecimalFormat;
public class Household
{
private int occ;
private double income;
DecimalFormat money = new DecimalFormat("0.00");
Household()
{
occ = 1;
income = 0.00;
System.out.println("The house before the set methods has "+ occ + " occupants and an income of $" + (money.format(income)));
}
public void methodThatUsesInstanceVariables()
{
int occ = 3;
double income = 55000;
System.out.print("The revised house has " + occ);
System.out.println(" occupants and an income of $" + (money.format(income)));
}
{
int occ = 2;
System.out.print("The second house has " + occ);
System.out.println(" occupants and an income of $" + (money.format(income)));
}
{
int occ = 7;
double income = 80000;
System.out.print("The third house has " + occ);
System.out.println(" occupants and an income of $" + (money.format(income)));
}
}