samedi 4 avril 2020

My java code uses an else if to calculate a product = answer always equals 0

My java code uses an else if to calculate a product = answer always equals 0 Not sure what I'm missing. Any help is much appreciated. Thanks


import javax.swing.JOptionPane;

public class CSC212{

static double PropertyTax; static double hValue; static double product;

public static void main(String[] args){

String State = JOptionPane.showInputDialog("Enter the location ex: CA, AZ, WA, ect...");

            if(State == "AL")

    {
        PropertyTax = 0.33;
    }

    else if(State == "AK")
    {
        PropertyTax = 1.04;
    }

    else if(State == "AZ")
    {
        PropertyTax = 0.72;
    }

    else if(State == "AR")
    {
        PropertyTax = 0.52;
    }

    else if(State == "CA")
    {
        PropertyTax = 0.74;
    }

    else if(State == "CO")
    {
        PropertyTax = 0.6;
    }

    else if(State == "CT")
    {
        PropertyTax = 1.63;
    }

    else if(State == "DE")
    {
        PropertyTax = 0.43;
    }

    else if(State == "FL")
    {
        PropertyTax = 0.97;
    }

    else if(State == "GA")
    {
        PropertyTax = 0.83;
    }

    else if(State == "HI")
    {
        PropertyTax = 0.26;
    }

    else if(State == "ID")
    {
        PropertyTax = 0.69;
    }

    else if(State == "IL")
    {
        PropertyTax = 1.73;
    }

    else if(State == "IN")
    {
        PropertyTax = 0.85;
    }

    else if(State == "IA")
    {
        PropertyTax = 1.29;
    }

    else if(State == "KS")
    {
        PropertyTax = 1.01;
    }

    else if(State == "KY")
    {
        PropertyTax = 0.72;
    }

    else if(State == "LA")
    {
        PropertyTax = 0.18;
    }

    else if(State == "ME")
    {
        PropertyTax = 1.09;
    }

    else if(State == "MD")
    {
        PropertyTax = 0.87;
    }

    else if(State == "MA")
    {
        PropertyTax = 1.04;
    }

    else if(State == "MI")
    {
        PropertyTax = 1.05;
    }

    else if(State == "MN")
    {
        PropertyTax = 1.05;
    }

    else if(State == "MS")
    {
        PropertyTax = 0.52;
    }

    else if(State == "MO")
    {
        PropertyTax = 0.91;
    }

    else if(State == "MT")
    {
        PropertyTax = 0.83;
    }

    else if(State == "NE")
    {
        PropertyTax = 1.76;
    }

    else if(State == "NV")
    {
        PropertyTax = 0.84;
    }

    else if(State == "NH")
    {
        PropertyTax = 1.86;
    }

    else if(State == "NJ")
    {
        PropertyTax = 1.89;
    }

    else if(State == "NM")
    {
        PropertyTax = 0.55;
    }

    else if(State == "NY")
    {
        PropertyTax = 1.23;
    }

    else if(State == "NC")
    {
        PropertyTax = 0.78;
    }

    else if(State == "ND")
    {
        PropertyTax = 1.42;
    }

    else if(State == "OH")
    {
        PropertyTax = 1.36;
    }

    else if(State == "OK")
    {
        PropertyTax = 0.74;
    }

    else if(State == "OR")
    {
        PropertyTax = 0.87;
    }

    else if(State == "PA")
    {
        PropertyTax = 1.35;
    }

    else if(State == "RI")
    {
        PropertyTax = 1.35;
    }

    else if(State == "SC")
    {
        PropertyTax = 0.5;
    }

    else if(State == "D.C.")
    {
        PropertyTax = 0.46;
    }

    else if(State == "SD")
    {
        PropertyTax = 1.28;
    }

    else if(State == "TN")
    {
        PropertyTax = 0.86;
    }

    else if(State == "TX")
    {
        PropertyTax = 1.18;
    }

    else if(State == "UT")
    {
        PropertyTax = 0.6;
    }

    else if(State == "VT")
    {
        PropertyTax = 1.59;
    }

    else if(State == "WA")
    {
        PropertyTax = 0.92;
    }

    else if(State == "WV")
    {
        PropertyTax = 0.49;
    }

    else if(State == "WI")
    {
        PropertyTax = 1.76;
    }

    else if(State == "WY")
    {
        PropertyTax = 0.58;
    }

String houseValue = JOptionPane.showInputDialog("Enter the value of the home");
    hValue = Integer.parseInt(houseValue);


product = PropertyTax * hValue;

JOptionPane.showMessageDialog(null, "The property tax is " +product);

        }

}


My java code uses an else if to calculate a product = answer always equals 0 Not sure what I'm missing. Any help is much appreciated. Thanks


Aucun commentaire:

Enregistrer un commentaire