import java.util.Scanner;
public class Taxes {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.printf("Enter the employees first name: ");
Scanner input = new Scanner(System.in);
String fName = input.nextLine();
System.out.printf("Enter the employees last name: ");
String lName = input.nextLine();
System.out.printf("Enter the hours worked for the week: ");
double hours = input.nextDouble();
System.out.printf("Enter the hourly pay rate: ");
double pay = input.nextDouble();
double gross = hours * pay;
System.out.printf("Enter the federal tax withholding: ");
double fed = input.nextDouble();
double fTax = gross * fed;
System.out.printf("Enter the state tax withholding: ");
double state = input.nextDouble();
double sTax = gross * state;
double Ttax = sTax + fTax;
double net = gross - Ttax;
System.out.printf(
"Employee Name:%s %s\n\nHours Worked:%s hours\n\nPay Rate:$%.2f\n\nGross pay:$%.2f\n\nDeductions: \n\n\tFederal Withholding:(%.2f%%)$%.2f \n\n"
+ "\tState Withholding:(%.2f%%)$%.2f\n\n\tTotal Witholding:$%.2f\n\nNet Pay:$%.2f",
fName, lName, hours, pay, gross, fed, fTax, state, sTax, Ttax, net);
input.close();
}
}
Federal ve Eyalet vergisi stopajlarının yüzde olarak gösterilmesi için iki değişken daha bildirmem gerekiyor.Baskı hızıyla yüzdelerin formatlanması
statewit = sTax * 100;
fedwit = fTax * 100;
: I (20.00%) Ben gibi altta yeni bir değişken bildirerek denedim
gibi bir bütün yüzde dönmelerini gerek (00.20%) olarak
Örnek gösteriyorlar Yüzdelerini istediğim gibi döndürmek için ama sonunda toplamı net olmaya eğilimlidir.
Herhangi bir yardım çok takdir edilecektir, teşekkürler!
java düzeltilmiş, == ben anladım javascript – Neal
:-(: programcı tamsayı kongre
DÜZENLEME tutarsanız çift, BigDecimal, tamsayı türleri de onun davranışı ile kullanılabilir veya olabilir! – jgills
Eğer öyleyse, bir yanıt gönderin ve geçerli olarak işaretleyin böylece aynı sıkıntıya sahip insanlar deneyimlerinizden yararlanabilirler – tommus