Reputation: 21
New to java, i am trying to get output of variables grossPayConv, taxesConv and netPayConv to have the output of XX.XX(having 2 places after the decimal). i believe i am casting wrong or something. i keep getting numbers with no values after the decimal. thanks, sorry for the basic question, can't seem to get it.
P.S = if your curious about the variable names... Conv - meaning conversion
System.out.println("hours worked: ");
double hours = input2.nextDouble();
System.out.println("hourly pay rate: ");
double payHours = input3.nextDouble();
double grossPay = payHours*hours;
double grossPayConv = (int)(grossPay*100)/100;
double taxes = grossPay*TX;
double taxesConv = (int)(taxes * 100) / 100;
double netPay = grossPay-taxes;
double netPayConv = (int)(netPay*100)/100;
Upvotes: 0
Views: 71
Reputation: 4923
Why are you casting the output to int.Update as below :
double grossPayConv = (grossPay*100)/100;
Upvotes: 1