So, for my homework, I have to make a program that allows the user to enter in the highest amount of money they are willing to pay for a house as a whole number. Here's the catch; I have to use if-else statements and JOptionPane dialog boxes.
So I came up with this code:
import javax.swing.JOptionPane;
public class housingDecision {
public static void main(String[] args) {
//listed things that need to be identified
int houseMoney;
String input;
input = JOptionPane. showInputDialog("How much money do you have?");
//making the input be listed by the user
houseMoney = Integer. parseInt(input);
//set up so that if its more than the parameters, itll move on to the next if else statement
if (houseMoney >= 250000 && houseMoney <= 100000 );
{
input = "You can afford a Townhouse!";
}
if(houseMoney >= 250001 && houseMoney <= 400000);
{
input = "You can afford a Single Family House!";
}
if (houseMoney >= 400001 && houseMoney <= 800000);
{
input = "You can afford a Luxury House!";
}
if (houseMoney >= 800001);
{
input = "Wow! You can Afford a mansion!";
}
}
}
However, it does not run when a whole number is input. What do I need to change so this isn't a problem anymore?