Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

public static void main (String[] args) throws FileNotFoundException { PrintWrit

ID: 3653020 • Letter: P

Question

public static void main (String[] args) throws FileNotFoundException { PrintWriter outFile = new PrintWriter("info.out"); //declare variables double fedTax = .15; double stateTax = .035; double ssTax = .0575; double medTax = .0275; double penPlan = .05; double healthIns = 75; double netPay; double gross; double fedOut; double stateOut; double ssOut; double medOut; double penOut; double totalTax; String name; String grossPay; //prompt user name = JOptionPane.showInputDialog("Enter your first and last name: "); grossPay = JOptionPane.showInputDialog("Enter your gross amount: "); gross = Double.parseDouble(grossPay); outFile.println(name); //calculate taxes to take out fedOut = gross * fedTax; stateOut = gross * stateTax; ssOut = gross * ssTax; medOut = gross * medTax; penOut = gross * penPlan; totalTax = fedOut + stateOut + ssOut + medOut + penOut; // calculate net pay netPay = gross - totalTax; // display results outFile.println("name"); outFile.printf("Gross Amount: %.2f %n", gross); outFile.printf("Federal Tax: %.2f %n", fedOut); outFile.printf("State Tax: %.2f %n", stateOut); outFile.printf("Social Security Tax: %.2f %n", ssOut); outFile.printf("Medicare/Medicaid Tax: %.2f %n", medOut); outFile.printf("Pension Plan: %.2f %n", penOut); outFile.printf("Health Insurance: %.2f %n",healthIns); outFile.printf("Net Pay: %.2f %n", netPay); outFile.close(); //outfile close }//class close }//static void main close

Explanation / Answer

import java.io.FileNotFoundException; import java.io.PrintWriter; import javax.swing.JOptionPane; public class MonthlyPaycheck { public static void main(String[] args) throws FileNotFoundException { PrintWriter outFile = new PrintWriter("info.out"); double fedTax = .15; double stateTax = .035; double ssTax = .0575; double medTax = .0275; double penPlan = .05; double healthIns = 75; double netPay; double gross; double fedOut; double stateOut; double ssOut; double medOut; double penOut; double totalTax; String name; String grossPay; name = JOptionPane.showInputDialog("Enter your first and last name: "); grossPay = JOptionPane.showInputDialog("Enter your gross amount: "); gross = Double.parseDouble(grossPay); outFile.println(name); fedOut = gross * fedTax; stateOut = gross * stateTax; ssOut = gross * ssTax; medOut = gross * medTax; penOut = gross * penPlan; totalTax = fedOut + stateOut + ssOut + medOut + penOut; netPay = gross - totalTax; outFile.println("name"); outFile.printf("Gross Amount: %.2f %n", gross); outFile.printf("Federal Tax: %.2f %n", fedOut); outFile.printf("State Tax: %.2f %n", stateOut); outFile.printf("Social Security Tax: %.2f %n", ssOut); outFile.printf("Medicare/Medicaid Tax: %.2f %n", medOut); outFile.printf("Pension Plan: %.2f %n", penOut); outFile.printf("Health Insurance: %.2f %n", healthIns); outFile.printf("Net Pay: %.2f %n", netPay); outFile.close(); } }