mardi 24 octobre 2017

Why isn't my initialized value changing?

I'm trying to calculate commission rates and I can't figure out why my initialized dRate value isn't changing to the value I specified in my if statement.I've tried changing the variable data type and I've tried multiplying the value in the if statement by 100 to make it 2 but the initialized value still didn't change.

        double dSales;      //holds sales amount as input by the user
        double dRate;       //holds the  rate of comission
        dRate=1.0;
        double dComission;  //holds the amount of comission
        dComission = 1.0;
        int iRate;
        iRate = 1;




        Scanner kb = new Scanner (System.in);
        DecimalFormat df = new DecimalFormat("$0,000.00");


        System.out.print("Enter sales Amount: ");
        dSales = kb.nextDouble();
        System.out.println("Sales Amount: " + df.format(dSales)+"\t" + "Rate: " +dRate+"%"+ " Comission: " +dComission);



        if(dSales<5000.0)
        {
            dRate = 0.2;
            dComission =dComission* dSales *dRate;


        }//end if(dSales)
        else
        {


        }

Aucun commentaire:

Enregistrer un commentaire