I have learned HTML, CSS, JAVASCRIPT, & some PYTHON
// Construct Scanner object and DecimalFormat object
Scanner sc = new Scanner(System.in);
DecimalFormat currency = new DecimalFormat(“$#,##0.00”);
// Display welcome message
System.out.println(WELCOME_MESSAGE);
System.out.println(" ");
// Loop while user chooses Y or y
do{
// Get user input for salary
System.out.print("Enter salary: ");
salary = sc.nextDouble();
// As long as salary input is NOT within the valid range, prompt again
while(salary < 0 || salary > 300000){
System.out.print("Error - Enter salary between 0 and 300000: ");
salary = sc.nextDouble();
}
System.out.print("Enter number of dependents: ");
numDependents = sc.nextDouble();
// As long as nbr of dependents is NOT within the valid range, prompt again
while(numDependents < 0 || numDependents > 20){
System.out.print("Error - Enter number of dependents between 0 and 20: ");
numDependents = sc.nextDouble();
}
System.out.println(" ");
// Perform calculations
stateTax = salary * .065;
federalTax = salary * .28;
dependentDeduction = (salary * .025) * numDependents;
totalWithholding = stateTax + federalTax;
takeHomePay = (salary - totalWithholding) + dependentDeduction;
// Display formatted output
System.out.println("State Tax:\t\t" + currency.format(stateTax));
System.out.println("Federal Tax:\t\t" + currency.format(federalTax));
System.out.println("Dependent Deduction:\t" + currency.format(dependentDeduction));
System.out.println("Salary:\t\t\t" + currency.format(salary));
System.out.println("Take Home Pay:\t\t" + currency.format(takeHomePay));
System.out.println(" "s);
// see if user wants to enter another
System.out.print("Would you like to enter data for another employee? (y/n): ");
enterAnother = sc.next();
}
// as long as user input is not "Y"/"y" and not "N"/"n", prompt again
while(enterAnother.equalsIgnoreCase("Y"));
System.exit(0);
}
This code may seem foreign to most reading this, but this program is to calculate an employee’s payroll after placing information. Straightforward explanation with a paragraph’s worth of code.